From 3bea1a83900a9854f2c0648eb41befe64d03b651 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 9 Feb 2024 23:44:50 +0200 Subject: [PATCH 1/2] dev: fix govet nilness lint issues --- .golangci.yml | 4 +++- pkg/lint/lintersdb/manager.go | 19 ++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b9c90afe1b2d..d84831265105 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,7 +52,6 @@ linters-settings: - strings.SplitN govet: - check-shadowing: true settings: printf: funcs: @@ -60,6 +59,9 @@ linters-settings: - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + enable: + - nilness + - shadow errorlint: asserts: false lll: diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 4a3c1b4d64f4..f0e43cee1139 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -236,25 +236,18 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { wrapcheckCfg = &m.cfg.LintersSettings.Wrapcheck wslCfg = &m.cfg.LintersSettings.WSL - if govetCfg != nil { - govetCfg.Go = m.cfg.Run.Go - } - - if gocriticCfg != nil { - gocriticCfg.Go = trimGoVersion(m.cfg.Run.Go) - } - - if gofumptCfg != nil && gofumptCfg.LangVersion == "" { + govetCfg.Go = m.cfg.Run.Go + gocriticCfg.Go = trimGoVersion(m.cfg.Run.Go) + if gofumptCfg.LangVersion == "" { gofumptCfg.LangVersion = m.cfg.Run.Go } - - if staticcheckCfg != nil && staticcheckCfg.GoVersion == "" { + if staticcheckCfg.GoVersion == "" { staticcheckCfg.GoVersion = trimGoVersion(m.cfg.Run.Go) } - if gosimpleCfg != nil && gosimpleCfg.GoVersion == "" { + if gosimpleCfg.GoVersion == "" { gosimpleCfg.GoVersion = trimGoVersion(m.cfg.Run.Go) } - if stylecheckCfg != nil && stylecheckCfg.GoVersion != "" { + if stylecheckCfg.GoVersion != "" { stylecheckCfg.GoVersion = trimGoVersion(m.cfg.Run.Go) } } From e61bd8cd27920c64650562e25a25f42bdf11f3b8 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 10 Feb 2024 01:44:14 +0100 Subject: [PATCH 2/2] review --- pkg/lint/lintersdb/manager.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index f0e43cee1139..fdc73ec734a1 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -237,10 +237,14 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { wslCfg = &m.cfg.LintersSettings.WSL govetCfg.Go = m.cfg.Run.Go + gocriticCfg.Go = trimGoVersion(m.cfg.Run.Go) + if gofumptCfg.LangVersion == "" { gofumptCfg.LangVersion = m.cfg.Run.Go } + + // staticcheck related linters. if staticcheckCfg.GoVersion == "" { staticcheckCfg.GoVersion = trimGoVersion(m.cfg.Run.Go) }