fix code style issues reported by golint

This commit is contained in:
Wenkai Yin 2017-09-19 17:16:54 +08:00
parent 9c6468f963
commit f0946b63cf
5 changed files with 10 additions and 29 deletions

View File

@ -115,9 +115,5 @@ func (c *cfgStore) Write(config map[string]interface{}) error {
return err return err
} }
if err = ioutil.WriteFile(c.path, b, 0600); err != nil { return ioutil.WriteFile(c.path, b, 0600)
return err
}
return nil
} }

View File

@ -267,8 +267,5 @@ func deleteRepository(name string) error {
} }
func clearRepositoryData() error { func clearRepositoryData() error {
if err := ClearTable(models.RepoTable); err != nil { return ClearTable(models.RepoTable)
return err
}
return nil
} }

View File

@ -42,11 +42,7 @@ func (s *sqlite) Register(alias ...string) error {
if len(alias) != 0 { if len(alias) != 0 {
an = alias[0] an = alias[0]
} }
if err := orm.RegisterDataBase(an, "sqlite3", s.file); err != nil { return orm.RegisterDataBase(an, "sqlite3", s.file)
return err
}
return nil
} }
// Name returns the name of SQLite // Name returns the name of SQLite

View File

@ -15,6 +15,10 @@ package job
import ( import (
"fmt" "fmt"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/vmware/harbor/src/common" "github.com/vmware/harbor/src/common"
"github.com/vmware/harbor/src/common/dao" "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/log"
"github.com/vmware/harbor/src/common/utils/test" "github.com/vmware/harbor/src/common/utils/test"
"github.com/vmware/harbor/src/jobservice/config" "github.com/vmware/harbor/src/jobservice/config"
"os"
"strconv"
"testing"
) )
var repJobID, scanJobID int64 var repJobID, scanJobID int64
@ -192,10 +193,7 @@ func clearRepJobData() error {
if err := dao.ClearTable(models.RepPolicyTable); err != nil { if err := dao.ClearTable(models.RepPolicyTable); err != nil {
return err return err
} }
if err := dao.ClearTable(models.RepTargetTable); err != nil { return dao.ClearTable(models.RepTargetTable)
return err
}
return nil
} }
func prepareScanJobData() error { func prepareScanJobData() error {
@ -220,8 +218,5 @@ func clearScanJobData() error {
if err := dao.ClearTable(models.ScanJobTable); err != nil { if err := dao.ClearTable(models.ScanJobTable); err != nil {
return err return err
} }
if err := dao.ClearTable(models.ScanOverviewTable); err != nil { return dao.ClearTable(models.ScanOverviewTable)
return err
}
return nil
} }

View File

@ -357,10 +357,7 @@ func validate(user models.User) error {
if isIllegalLength(user.Password, 8, 20) { if isIllegalLength(user.Password, 8, 20) {
return fmt.Errorf("password with illegal length") return fmt.Errorf("password with illegal length")
} }
if err := commonValidate(user); err != nil { return commonValidate(user)
return err
}
return nil
} }
//commonValidate validates email, realname, comment information when user register or change their profile //commonValidate validates email, realname, comment information when user register or change their profile