config: spread go version on linter's configurations (#2913)
This commit is contained in:
parent
97eea6ea49
commit
4b218e664c
@ -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: ["*"]
|
||||
@ -1543,6 +1545,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: ["*"]
|
||||
@ -1551,6 +1554,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: ["*"]
|
||||
|
@ -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.
|
||||
|
@ -318,9 +318,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 {
|
||||
@ -527,6 +529,7 @@ type RowsErrCheckSettings struct {
|
||||
}
|
||||
|
||||
type StaticCheckSettings struct {
|
||||
// Deprecated: use the global `run.go` instead.
|
||||
GoVersion string `mapstructure:"go"`
|
||||
|
||||
Checks []string `mapstructure:"checks"`
|
||||
|
@ -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(
|
||||
|
@ -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 {
|
||||
|
@ -240,6 +240,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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user