diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 3a890a04ac9b..61b94f60ce98 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1074,40 +1074,6 @@ linters-settings: - Katakana govet: - # Report about shadowed variables. - # Default: false - check-shadowing: true - - # Settings per analyzer. - settings: - # Analyzer name, run `go tool vet help` to see all analyzers. - printf: - # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`). - # Default: [] - funcs: - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (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 - shadow: - # Whether to be strict about shadowing; can be noisy. - # Default: false - strict: true - unusedresult: - # Comma-separated list of functions whose results must be used - # (in addition to default: - # context.WithCancel, context.WithDeadline, context.WithTimeout, context.WithValue, errors.New, fmt.Errorf, - # fmt.Sprint, fmt.Sprintf, sort.Reverse - # ). - # Default: [] - funcs: - - pkg.MyFunc - # Comma-separated list of names of methods of type func() string whose results must be used - # (in addition to default Error,String) - # Default: [] - stringmethods: - - MyMethod - # Disable all analyzers. # Default: false disable-all: true @@ -1214,6 +1180,36 @@ linters-settings: - unusedresult - unusedwrite + # Settings per analyzer. + settings: + # Analyzer name, run `go tool vet help` to see all analyzers. + printf: + # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`). + # Default: [] + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (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 + shadow: + # Whether to be strict about shadowing; can be noisy. + # Default: false + strict: true + unusedresult: + # Comma-separated list of functions whose results must be used + # (in addition to default: + # context.WithCancel, context.WithDeadline, context.WithTimeout, context.WithValue, errors.New, fmt.Errorf, + # fmt.Sprint, fmt.Sprintf, sort.Reverse + # ). + # Default: [] + funcs: + - pkg.MyFunc + # Comma-separated list of names of methods of type func() string whose results must be used + # (in addition to default Error,String) + # Default: [] + stringmethods: + - MyMethod + grouper: # Require the use of a single global 'const' declaration only. # Default: false diff --git a/.golangci.yml b/.golangci.yml index a947437ffc08..804b0b98ac23 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -155,6 +155,8 @@ issues: - path: pkg/commands/run.go linters: [staticcheck] text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead." + - path: pkg/golinters/govet.go + text: "SA1019: settings.CheckShadowing is deprecated: the linter should be enabled inside `Enable`." - path: pkg/golinters/gofumpt.go linters: [staticcheck] diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 50ef3f5f7fe9..fb5c2a468cde 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -1661,11 +1661,6 @@ "type": "object", "additionalProperties": false, "properties": { - "check-shadowing": { - "description": "Report shadowed variables.", - "type": "boolean", - "default": true - }, "settings": { "description": "Settings per analyzer. Map of analyzer name to specific settings.\nRun `go tool vet help` to find out more.", "type": "object", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 107f998bbbd1..6097be06b105 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -598,14 +598,17 @@ type GosmopolitanSettings struct { } type GovetSettings struct { - Go string `mapstructure:"-"` - CheckShadowing bool `mapstructure:"check-shadowing"` - Settings map[string]map[string]any + Go string `mapstructure:"-"` Enable []string Disable []string EnableAll bool `mapstructure:"enable-all"` DisableAll bool `mapstructure:"disable-all"` + + Settings map[string]map[string]any + + // Deprecated: the linter should be enabled inside `Enable`. + CheckShadowing bool `mapstructure:"check-shadowing"` } func (cfg *GovetSettings) Validate() error { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index f2814e962fa2..782daa4c9250 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -322,6 +322,13 @@ func (l *Loader) handleDeprecation() error { l.cfg.Output.Formats = f } + // Deprecated since v1.57.0, + // but it was unofficially deprecated since v1.19 (2019) (https://github.com/golangci/golangci-lint/pull/697). + if l.cfg.LintersSettings.Govet.CheckShadowing { + l.warn("The configuration option `govet.check-shadowing` is deprecated. " + + "Please enable `shadow` instead, if you are not using `enable-all`.") + } + return nil } diff --git a/test/testdata/configs/govet.yml b/test/testdata/configs/govet.yml index 86e8edd3377c..8a0d68da612c 100644 --- a/test/testdata/configs/govet.yml +++ b/test/testdata/configs/govet.yml @@ -1,3 +1,4 @@ linters-settings: govet: - check-shadowing: true + enable: + - shadow