diff --git a/src/adminserver/systemcfg/store/json/driver_json.go b/src/adminserver/systemcfg/store/json/driver_json.go index f16bc9560..4e795a52a 100644 --- a/src/adminserver/systemcfg/store/json/driver_json.go +++ b/src/adminserver/systemcfg/store/json/driver_json.go @@ -115,9 +115,5 @@ func (c *cfgStore) Write(config map[string]interface{}) error { return err } - if err = ioutil.WriteFile(c.path, b, 0600); err != nil { - return err - } - - return nil + return ioutil.WriteFile(c.path, b, 0600) } diff --git a/src/common/dao/repository_test.go b/src/common/dao/repository_test.go index 74eadc8a2..aefbce0e3 100644 --- a/src/common/dao/repository_test.go +++ b/src/common/dao/repository_test.go @@ -267,8 +267,5 @@ func deleteRepository(name string) error { } func clearRepositoryData() error { - if err := ClearTable(models.RepoTable); err != nil { - return err - } - return nil + return ClearTable(models.RepoTable) } diff --git a/src/common/dao/sqlite.go b/src/common/dao/sqlite.go index e65a29a71..6e7e1ff79 100644 --- a/src/common/dao/sqlite.go +++ b/src/common/dao/sqlite.go @@ -42,11 +42,7 @@ func (s *sqlite) Register(alias ...string) error { if len(alias) != 0 { an = alias[0] } - if err := orm.RegisterDataBase(an, "sqlite3", s.file); err != nil { - return err - } - - return nil + return orm.RegisterDataBase(an, "sqlite3", s.file) } // Name returns the name of SQLite diff --git a/src/jobservice/job/job_test.go b/src/jobservice/job/job_test.go index 48f7b608a..5a66c9e1c 100644 --- a/src/jobservice/job/job_test.go +++ b/src/jobservice/job/job_test.go @@ -15,6 +15,10 @@ package job import ( "fmt" + "os" + "strconv" + "testing" + "github.com/stretchr/testify/assert" "github.com/vmware/harbor/src/common" "github.com/vmware/harbor/src/common/dao" @@ -22,9 +26,6 @@ import ( "github.com/vmware/harbor/src/common/utils/log" "github.com/vmware/harbor/src/common/utils/test" "github.com/vmware/harbor/src/jobservice/config" - "os" - "strconv" - "testing" ) var repJobID, scanJobID int64 @@ -192,10 +193,7 @@ func clearRepJobData() error { if err := dao.ClearTable(models.RepPolicyTable); err != nil { return err } - if err := dao.ClearTable(models.RepTargetTable); err != nil { - return err - } - return nil + return dao.ClearTable(models.RepTargetTable) } func prepareScanJobData() error { @@ -220,8 +218,5 @@ func clearScanJobData() error { if err := dao.ClearTable(models.ScanJobTable); err != nil { return err } - if err := dao.ClearTable(models.ScanOverviewTable); err != nil { - return err - } - return nil + return dao.ClearTable(models.ScanOverviewTable) } diff --git a/src/ui/api/user.go b/src/ui/api/user.go index 19ff9b612..d96b02dbd 100644 --- a/src/ui/api/user.go +++ b/src/ui/api/user.go @@ -357,10 +357,7 @@ func validate(user models.User) error { if isIllegalLength(user.Password, 8, 20) { return fmt.Errorf("password with illegal length") } - if err := commonValidate(user); err != nil { - return err - } - return nil + return commonValidate(user) } //commonValidate validates email, realname, comment information when user register or change their profile