enable gosimple linter

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL 2023-03-11 22:43:45 +01:00
parent 709e775b13
commit 5a7619c019
6 changed files with 7 additions and 9 deletions

View File

@ -3,13 +3,13 @@ linters:
- contextcheck - contextcheck
- gci - gci
- gofumpt - gofumpt
- gosimple
- ineffassign - ineffassign
- misspell - misspell
- nonamedreturns - nonamedreturns
- staticcheck - staticcheck
disable: disable:
- errcheck - errcheck
- gosimple
linters-settings: linters-settings:
gci: gci:

View File

@ -305,7 +305,7 @@ func (l *DHCPLease) maintain() {
switch state { switch state {
case leaseStateBound: case leaseStateBound:
sleepDur = l.renewalTime.Sub(time.Now()) sleepDur = time.Until(l.renewalTime)
if sleepDur <= 0 { if sleepDur <= 0 {
log.Printf("%v: renewing lease", l.clientID) log.Printf("%v: renewing lease", l.clientID)
state = leaseStateRenewing state = leaseStateRenewing

View File

@ -47,7 +47,7 @@ func cmdCheck(args *skel.CmdArgs) error {
defer store.Close() defer store.Close()
containerIpFound := store.FindByID(args.ContainerID, args.IfName) containerIpFound := store.FindByID(args.ContainerID, args.IfName)
if containerIpFound == false { if !containerIpFound {
return fmt.Errorf("host-local: Failed to find address added by container %v", args.ContainerID) return fmt.Errorf("host-local: Failed to find address added by container %v", args.ContainerID)
} }

View File

@ -1258,7 +1258,6 @@ func (tester *testerV03x) cmdAddTest(tc testCase, dataDir string) (types.Result,
} }
func (tester *testerV03x) cmdCheckTest(tc testCase, conf *Net, dataDir string) { func (tester *testerV03x) cmdCheckTest(tc testCase, conf *Net, dataDir string) {
return
} }
func (tester *testerV03x) cmdDelTest(tc testCase, dataDir string) { func (tester *testerV03x) cmdDelTest(tc testCase, dataDir string) {
@ -1489,7 +1488,6 @@ func (tester *testerV01xOr02x) cmdAddTest(tc testCase, dataDir string) (types.Re
} }
func (tester *testerV01xOr02x) cmdCheckTest(tc testCase, conf *Net, dataDir string) { func (tester *testerV01xOr02x) cmdCheckTest(tc testCase, conf *Net, dataDir string) {
return
} }
func (tester *testerV01xOr02x) cmdDelTest(tc testCase, dataDir string) { func (tester *testerV01xOr02x) cmdDelTest(tc testCase, dataDir string) {

View File

@ -167,7 +167,7 @@ func isolationStage2BridgeRule(bridgeName string) []string {
} }
func withDefaultComment(rule []string) []string { func withDefaultComment(rule []string) []string {
defaultComment := fmt.Sprintf("CNI firewall plugin rules (ingressPolicy: same-bridge)") defaultComment := "CNI firewall plugin rules (ingressPolicy: same-bridge)"
return withComment(rule, defaultComment) return withComment(rule, defaultComment)
} }

View File

@ -369,7 +369,7 @@ func cmdAdd(args *skel.CmdArgs) error {
updateResultsMacAddr(tuningConf, args.IfName, tuningConf.Mac) updateResultsMacAddr(tuningConf, args.IfName, tuningConf.Mac)
} }
if tuningConf.Promisc != false { if tuningConf.Promisc {
if err = changePromisc(args.IfName, true); err != nil { if err = changePromisc(args.IfName, true); err != nil {
return err return err
} }
@ -514,7 +514,7 @@ func validateSysctlConf(tuningConf *TuningConf) error {
return err return err
} }
if !match { if !match {
return errors.New(fmt.Sprintf("Sysctl %s is not allowed. Only the following sysctls are allowed: %+v", sysctl, allowlist)) return fmt.Errorf("Sysctl %s is not allowed. Only the following sysctls are allowed: %+v", sysctl, allowlist)
} }
} }
return nil return nil
@ -579,7 +579,7 @@ func validateSysctlConflictingKeys(data []byte) error {
func validateArgs(args *skel.CmdArgs) error { func validateArgs(args *skel.CmdArgs) error {
if strings.Contains(args.IfName, string(os.PathSeparator)) { if strings.Contains(args.IfName, string(os.PathSeparator)) {
return errors.New(fmt.Sprintf("Interface name (%s) contains an invalid character %s", args.IfName, string(os.PathSeparator))) return fmt.Errorf("Interface name (%s) contains an invalid character %s", args.IfName, string(os.PathSeparator))
} }
return nil return nil
} }