diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 7451c8e361a7..6042a0c42c06 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -557,6 +557,7 @@ linters-settings: gofumpt: # Select the Go version to target. # Default: "1.15" + # Deprecated: use the global `run.go` instead. lang-version: "1.17" # Module path which contains the source code being formatted. @@ -699,6 +700,7 @@ linters-settings: gosimple: # Select the Go version to target. # Default: 1.13 + # Deprecated: use the global `run.go` instead. go: "1.15" # https://staticcheck.io/docs/options#checks # Default: ["*"] @@ -1538,6 +1540,7 @@ linters-settings: staticcheck: # Select the Go version to target. # Default: "1.13" + # Deprecated: use the global `run.go` instead. go: "1.15" # https://staticcheck.io/docs/options#checks # Default: ["*"] @@ -1546,6 +1549,7 @@ linters-settings: stylecheck: # Select the Go version to target. # Default: 1.13 + # Deprecated: use the global `run.go` instead. go: "1.15" # https://staticcheck.io/docs/options#checks # Default: ["*"] diff --git a/.golangci.yml b/.golangci.yml index 08c56f45a8ea..d8523cc58e47 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -134,6 +134,14 @@ issues: - path: pkg/commands/run.go text: "SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used." + - path: pkg/golinters/gofumpt.go + text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead." + - path: pkg/golinters/staticcheck_common.go + text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead." + - path: pkg/lint/lintersdb/manager.go + text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead." + + run: timeout: 5m go: '1.17' # TODO(ldez): we force to use an old version of Go for the CI and the tests. diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 3d47951783f3..bf81ef5459a4 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -317,9 +317,11 @@ type GoFmtSettings struct { } type GofumptSettings struct { + ModulePath string `mapstructure:"module-path"` + ExtraRules bool `mapstructure:"extra-rules"` + + // Deprecated: use the global `run.go` instead. LangVersion string `mapstructure:"lang-version"` - ModulePath string `mapstructure:"module-path"` - ExtraRules bool `mapstructure:"extra-rules"` } type GoHeaderSettings struct { @@ -522,6 +524,7 @@ type RowsErrCheckSettings struct { } type StaticCheckSettings struct { + // Deprecated: use the global `run.go` instead. GoVersion string `mapstructure:"go"` Checks []string `mapstructure:"checks"` diff --git a/pkg/golinters/staticcheck.go b/pkg/golinters/staticcheck.go index c7b7b3db4b74..673484630aba 100644 --- a/pkg/golinters/staticcheck.go +++ b/pkg/golinters/staticcheck.go @@ -9,7 +9,6 @@ import ( func NewStaticcheck(settings *config.StaticCheckSettings) *goanalysis.Linter { cfg := staticCheckConfig(settings) - analyzers := setupStaticCheckAnalyzers(staticcheck.Analyzers, getGoVersion(settings), cfg.Checks) return goanalysis.NewLinter( diff --git a/pkg/golinters/staticcheck_common.go b/pkg/golinters/staticcheck_common.go index dc6360d7e071..e54cf8e8baa5 100644 --- a/pkg/golinters/staticcheck_common.go +++ b/pkg/golinters/staticcheck_common.go @@ -24,8 +24,7 @@ func getGoVersion(settings *config.StaticCheckSettings) string { return goVersion } - // TODO: uses "1.13" for backward compatibility, but in the future (v2) must be set by using build.Default.ReleaseTags like staticcheck. - return "1.13" + return "1.17" } func setupStaticCheckAnalyzers(src []*lint.Analyzer, goVersion string, checks []string) []*analysis.Analyzer { diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 79777d312b2c..be5721159be6 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -238,6 +238,23 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { if govetCfg != nil { govetCfg.Go = m.cfg.Run.Go } + + if gofumptCfg != nil && gofumptCfg.LangVersion == "" { + gofumptCfg.LangVersion = m.cfg.Run.Go + } + + if staticcheckCfg != nil && staticcheckCfg.GoVersion == "" { + staticcheckCfg.GoVersion = m.cfg.Run.Go + } + if gosimpleCfg != nil && gosimpleCfg.GoVersion == "" { + gosimpleCfg.GoVersion = m.cfg.Run.Go + } + if stylecheckCfg != nil && stylecheckCfg.GoVersion != "" { + stylecheckCfg.GoVersion = m.cfg.Run.Go + } + if unusedCfg != nil && unusedCfg.GoVersion == "" { + unusedCfg.GoVersion = m.cfg.Run.Go + } } const megacheckName = "megacheck"