From 565c81fa8fd968bc2f87904d3af5320c3d793bd6 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 9 May 2024 00:01:54 +0300 Subject: [PATCH] dev: deprecate errcheck.ignore option (#4709) --- .golangci.yml | 3 +++ pkg/config/linters_settings.go | 4 +++- pkg/config/loader.go | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index ac5fe803f2de..7c21a62424cb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -167,6 +167,9 @@ issues: - path: pkg/golinters/errcheck/errcheck.go linters: [staticcheck] text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead" + - path: pkg/golinters/errcheck/errcheck.go + linters: [staticcheck] + text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead" - path: pkg/golinters/govet/govet.go linters: [staticcheck] text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable." diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index d793ef99711c..e204328421ce 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -371,11 +371,13 @@ type ErrcheckSettings struct { DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"` CheckTypeAssertions bool `mapstructure:"check-type-assertions"` CheckAssignToBlank bool `mapstructure:"check-blank"` - Ignore string `mapstructure:"ignore"` ExcludeFunctions []string `mapstructure:"exclude-functions"` // Deprecated: use ExcludeFunctions instead Exclude string `mapstructure:"exclude"` + + // Deprecated: use ExcludeFunctions instead + Ignore string `mapstructure:"ignore"` } type ErrChkJSONSettings struct { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index db23048b2dfc..a48381474c87 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -355,6 +355,7 @@ func (l *Loader) handleDeprecation() error { return nil } +//nolint:gocyclo // the complexity cannot be reduced. func (l *Loader) handleLinterOptionDeprecations() { // Deprecated since v1.57.0, // but it was unofficially deprecated since v1.19 (2019) (https://github.com/golangci/golangci-lint/pull/697). @@ -373,6 +374,12 @@ func (l *Loader) handleLinterOptionDeprecations() { l.log.Warnf("The configuration option `linters.errcheck.exclude` is deprecated, please use `linters.errcheck.exclude-functions`.") } + // Deprecated since v1.59.0, + // but it was unofficially deprecated since v1.13 (2018) (https://github.com/golangci/golangci-lint/pull/332). + if l.cfg.LintersSettings.Errcheck.Ignore != "" { + l.log.Warnf("The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.") + } + // Deprecated since v1.44.0. if l.cfg.LintersSettings.Gci.LocalPrefixes != "" { l.log.Warnf("The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.")