From 42a2731f8fda2a27c1f3f7bda493cb70ba4c5ee0 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 23:04:09 +0100 Subject: [PATCH 1/5] chore: fix typo in exclusion configuration --- jsonschema/golangci.next.jsonschema.json | 2 +- pkg/config/linters_exclusions.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 60f55f6733ee..771834a5b268 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -4260,7 +4260,7 @@ "type": "boolean", "default": false }, - "default": { + "presets": { "type": "array", "items": { "enum": [ diff --git a/pkg/config/linters_exclusions.go b/pkg/config/linters_exclusions.go index a07c5dc25ebf..20c1429ca6ff 100644 --- a/pkg/config/linters_exclusions.go +++ b/pkg/config/linters_exclusions.go @@ -23,7 +23,7 @@ const excludeRuleMinConditionsCount = 2 type LinterExclusions struct { Generated string `mapstructure:"generated"` WarnUnused bool `mapstructure:"warn-unused"` - Presets []string `mapstructure:"preset"` + Presets []string `mapstructure:"presets"` Rules []ExcludeRule `mapstructure:"rules"` Paths []string `mapstructure:"paths"` PathsExcept []string `mapstructure:"paths-except"` From 31b216c72637d76025cab4af26d2aa5e91db76f7 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 22:20:55 +0100 Subject: [PATCH 2/5] chore: remove deprecated settings --- pkg/config/formatters_settings.go | 6 +- pkg/config/issues.go | 2 - pkg/config/linters_settings.go | 29 ---- pkg/config/loader.go | 133 +-------------- pkg/config/output.go | 3 - pkg/config/run.go | 10 -- pkg/goformatters/gci/gci.go | 9 -- pkg/golinters/errcheck/errcheck.go | 162 +------------------ pkg/golinters/godot/godot.go | 5 - pkg/golinters/govet/govet.go | 5 - pkg/golinters/usestdlibvars/usestdlibvars.go | 4 +- 11 files changed, 12 insertions(+), 356 deletions(-) diff --git a/pkg/config/formatters_settings.go b/pkg/config/formatters_settings.go index 50f50aa225f5..51c16da660fd 100644 --- a/pkg/config/formatters_settings.go +++ b/pkg/config/formatters_settings.go @@ -31,9 +31,6 @@ type GciSettings struct { SkipGenerated bool `mapstructure:"skip-generated"` CustomOrder bool `mapstructure:"custom-order"` NoLexOrder bool `mapstructure:"no-lex-order"` - - // Deprecated: use Sections instead. - LocalPrefixes string `mapstructure:"local-prefixes"` } type GoFmtSettings struct { @@ -50,8 +47,7 @@ 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"` + LangVersion string `mapstructure:"-"` } type GoImportsSettings struct { diff --git a/pkg/config/issues.go b/pkg/config/issues.go index d5b6650f9533..6f546e7eaa3e 100644 --- a/pkg/config/issues.go +++ b/pkg/config/issues.go @@ -124,8 +124,6 @@ type Issues struct { Diff bool `mapstructure:"new"` NeedFix bool `mapstructure:"fix"` - - ExcludeGeneratedStrict *bool `mapstructure:"exclude-generated-strict"` // Deprecated: use ExcludeGenerated instead. } func (i *Issues) Validate() error { diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 6e76ad200143..5043d1102596 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -324,9 +324,6 @@ type BiDiChkSettings struct { type CopyLoopVarSettings struct { CheckAlias bool `mapstructure:"check-alias"` - - // Deprecated: use CheckAlias - IgnoreAlias *bool `mapstructure:"ignore-alias"` } type Cyclop struct { @@ -380,12 +377,6 @@ type ErrcheckSettings struct { CheckTypeAssertions bool `mapstructure:"check-type-assertions"` CheckAssignToBlank bool `mapstructure:"check-blank"` ExcludeFunctions []string `mapstructure:"exclude-functions"` - - // Deprecated: use ExcludeFunctions instead - Exclude string `mapstructure:"exclude"` - - // Deprecated: use ExcludeFunctions instead - Ignore string `mapstructure:"ignore"` } type ErrChkJSONSettings struct { @@ -534,9 +525,6 @@ type GodotSettings struct { Exclude []string `mapstructure:"exclude"` Capital bool `mapstructure:"capital"` Period bool `mapstructure:"period"` - - // Deprecated: use Scope instead - CheckAll *bool `mapstructure:"check-all"` } type GodoxSettings struct { @@ -605,9 +593,6 @@ type GovetSettings struct { 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 { @@ -834,9 +819,6 @@ type SlogLintSettings struct { KeyNamingCase string `mapstructure:"key-naming-case"` ForbiddenKeys []string `mapstructure:"forbidden-keys"` ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"` - - // Deprecated: use Context instead. - ContextOnly *bool `mapstructure:"context-only"` } type SpancheckSettings struct { @@ -850,9 +832,6 @@ type StaticCheckSettings struct { Initialisms []string `mapstructure:"initialisms"` // only for stylecheck DotImportWhitelist []string `mapstructure:"dot-import-whitelist"` // only for stylecheck HTTPStatusCodeWhitelist []string `mapstructure:"http-status-code-whitelist"` // only for stylecheck - - // Deprecated: use the global `run.go` instead. - GoVersion string `mapstructure:"go"` } func (s *StaticCheckSettings) HasConfiguration() bool { @@ -959,11 +938,6 @@ type UseStdlibVarsSettings struct { SQLIsolationLevel bool `mapstructure:"sql-isolation-level"` TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"` ConstantKind bool `mapstructure:"constant-kind"` - - // Deprecated - OSDevNull *bool `mapstructure:"os-dev-null"` - // Deprecated - SyslogPriority *bool `mapstructure:"syslog-priority"` } type UseTestingSettings struct { @@ -993,9 +967,6 @@ type UnusedSettings struct { ParametersAreUsed bool `mapstructure:"parameters-are-used"` LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"` GeneratedIsUsed bool `mapstructure:"generated-is-used"` - - // Deprecated - ExportedIsUsed *bool `mapstructure:"exported-is-used"` } type VarnamelenSettings struct { diff --git a/pkg/config/loader.go b/pkg/config/loader.go index 61e3a2aea038..b36c16d20d87 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -301,8 +301,6 @@ func (l *Loader) applyStringSliceHack() { l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags) l.appendStringSlice("exclude", &l.cfg.Issues.ExcludePatterns) - l.appendStringSlice("skip-dirs", &l.cfg.Run.SkipDirs) - l.appendStringSlice("skip-files", &l.cfg.Run.SkipFiles) l.appendStringSlice("exclude-dirs", &l.cfg.Issues.ExcludeDirs) l.appendStringSlice("exclude-files", &l.cfg.Issues.ExcludeFiles) } @@ -323,8 +321,8 @@ func (l *Loader) handleGoVersion() { l.cfg.LintersSettings.ParallelTest.Go = l.cfg.Run.Go - l.cfg.LintersSettings.GoFumpt.LangVersion = cmp.Or(l.cfg.LintersSettings.GoFumpt.LangVersion, l.cfg.Run.Go) - l.cfg.Formatters.Settings.GoFumpt.LangVersion = cmp.Or(l.cfg.Formatters.Settings.GoFumpt.LangVersion, l.cfg.Run.Go) + l.cfg.LintersSettings.GoFumpt.LangVersion = l.cfg.Run.Go + l.cfg.Formatters.Settings.GoFumpt.LangVersion = l.cfg.Run.Go trimmedGoVersion := goutil.TrimGoVersion(l.cfg.Run.Go) @@ -340,123 +338,13 @@ func (l *Loader) handleDeprecation() error { return nil } - // Deprecated since v1.57.0 - if len(l.cfg.Run.SkipFiles) > 0 { - l.log.Warnf("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.") - l.cfg.Issues.ExcludeFiles = l.cfg.Run.SkipFiles - } - - // Deprecated since v1.57.0 - if len(l.cfg.Run.SkipDirs) > 0 { - l.log.Warnf("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.") - l.cfg.Issues.ExcludeDirs = l.cfg.Run.SkipDirs - } - - // Deprecated since v1.57.0 - if l.cfg.Run.UseDefaultSkipDirs != nil { - l.log.Warnf("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`.") - l.cfg.Issues.UseDefaultExcludeDirs = *l.cfg.Run.UseDefaultSkipDirs - } - - // Deprecated since v1.57.0 - if l.cfg.Run.ShowStats != nil { - l.log.Warnf("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`") - l.cfg.Output.ShowStats = *l.cfg.Run.ShowStats - } - - // Deprecated since v1.63.0 - if l.cfg.Output.UniqByLine != nil { - l.log.Warnf("The configuration option `output.uniq-by-line` is deprecated, please use `issues.uniq-by-line`") - l.cfg.Issues.UniqByLine = *l.cfg.Output.UniqByLine - } - - // Deprecated since v1.59.0 - if l.cfg.Issues.ExcludeGeneratedStrict != nil { - l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`") - if !*l.cfg.Issues.ExcludeGeneratedStrict { - l.cfg.Issues.ExcludeGenerated = "strict" // Don't use the constants to avoid cyclic dependencies. - } - } - l.handleLinterOptionDeprecations() return nil } -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). - if l.cfg.LintersSettings.Govet.CheckShadowing != nil { - l.log.Warnf("The configuration option `linters.govet.check-shadowing` is deprecated. " + - "Please enable `shadow` instead, if you are not using `enable-all`.") - } - - if l.cfg.LintersSettings.CopyLoopVar.IgnoreAlias != nil { - l.log.Warnf("The configuration option `linters.copyloopvar.ignore-alias` is deprecated and ignored," + - "please use `linters.copyloopvar.check-alias`.") - } - - // Deprecated since v1.42.0. - if l.cfg.LintersSettings.Errcheck.Exclude != "" { - 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`.") - } - - // Deprecated since v1.33.0. - if l.cfg.LintersSettings.Godot.CheckAll != nil { - l.log.Warnf("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.") - } - - // Deprecated since v1.47.0 - if l.cfg.LintersSettings.GoFumpt.LangVersion != "" { - l.log.Warnf("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.") - } - - // Deprecated since v1.47.0 - if l.cfg.LintersSettings.Staticcheck.GoVersion != "" { - l.log.Warnf("The configuration option `linters.staticcheck.go` is deprecated, please use global `run.go`.") - } - - // Deprecated since v1.47.0 - if l.cfg.LintersSettings.Gosimple.GoVersion != "" { - l.log.Warnf("The configuration option `linters.gosimple.go` is deprecated, please use global `run.go`.") - } - - // Deprecated since v1.47.0 - if l.cfg.LintersSettings.Stylecheck.GoVersion != "" { - l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.") - } - - // Deprecated since v1.60.0 - if l.cfg.LintersSettings.Unused.ExportedIsUsed != nil { - l.log.Warnf("The configuration option `linters.unused.exported-is-used` is deprecated.") - } - - // Deprecated since v1.58.0 - if l.cfg.LintersSettings.SlogLint.ContextOnly != nil { - l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.") - l.cfg.LintersSettings.SlogLint.Context = cmp.Or(l.cfg.LintersSettings.SlogLint.Context, "all") - } - - // Deprecated since v1.51.0 - if l.cfg.LintersSettings.UseStdlibVars.OSDevNull != nil { - l.log.Warnf("The configuration option `linters.usestdlibvars.os-dev-null` is deprecated.") - } - - // Deprecated since v1.51.0 - if l.cfg.LintersSettings.UseStdlibVars.SyslogPriority != nil { - l.log.Warnf("The configuration option `linters.usestdlibvars.syslog-priority` is deprecated.") - } +func (*Loader) handleLinterOptionDeprecations() { + // The function is empty but deprecations will happen in the future. } func (l *Loader) handleEnableOnlyOption() error { @@ -519,18 +407,9 @@ func (l *Loader) handleFormatterExclusions() { }) } } -func (l *Loader) handleFormatterDeprecations() { - // Deprecated since v1.44.0. - if l.cfg.Formatters.Settings.Gci.LocalPrefixes != "" { - l.log.Warnf("The configuration option `formatters.settings.gci.local-prefixes` is deprecated, " + - "please use `prefix()` inside `formatters.settings.gci.sections`.") - } - // Deprecated since v1.47.0 - if l.cfg.Formatters.Settings.GoFumpt.LangVersion != "" { - l.log.Warnf("The configuration option `formatters.settings.gofumpt.lang-version` is deprecated, " + - "please use global `run.go`.") - } +func (*Loader) handleFormatterDeprecations() { + // The function is empty but deprecations will happen in the future. } func customDecoderHook() viper.DecoderConfigOption { diff --git a/pkg/config/output.go b/pkg/config/output.go index 7c0dd70bc3d0..a2b1eb9980cf 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -13,9 +13,6 @@ type Output struct { SortOrder []string `mapstructure:"sort-order"` PathPrefix string `mapstructure:"path-prefix"` ShowStats bool `mapstructure:"show-stats"` - - // Deprecated: use [Issues.UniqByLine] instead. - UniqByLine *bool `mapstructure:"uniq-by-line"` } func (o *Output) Validate() error { diff --git a/pkg/config/run.go b/pkg/config/run.go index 8e00f1e6dcbb..dcd6a20e2ff6 100644 --- a/pkg/config/run.go +++ b/pkg/config/run.go @@ -27,16 +27,6 @@ type Run struct { AllowParallelRunners bool `mapstructure:"allow-parallel-runners"` AllowSerialRunners bool `mapstructure:"allow-serial-runners"` - - // Deprecated: use Issues.ExcludeFiles instead. - SkipFiles []string `mapstructure:"skip-files"` - // Deprecated: use Issues.ExcludeDirs instead. - SkipDirs []string `mapstructure:"skip-dirs"` - // Deprecated: use Issues.UseDefaultExcludeDirs instead. - UseDefaultSkipDirs *bool `mapstructure:"skip-dirs-use-default"` - - // Deprecated: use Output.ShowStats instead. - ShowStats *bool `mapstructure:"show-stats"` } func (r *Run) Validate() error { diff --git a/pkg/goformatters/gci/gci.go b/pkg/goformatters/gci/gci.go index f28b5b98a9dd..76e8186cc960 100644 --- a/pkg/goformatters/gci/gci.go +++ b/pkg/goformatters/gci/gci.go @@ -2,7 +2,6 @@ package gci import ( "context" - "fmt" gcicfg "github.com/daixiang0/gci/pkg/config" "github.com/daixiang0/gci/pkg/gci" @@ -41,14 +40,6 @@ func New(settings *config.GciSettings) (*Formatter, error) { ModPath: modPath, } - if settings.LocalPrefixes != "" { - cfg.SectionStrings = []string{ - "standard", - "default", - fmt.Sprintf("prefix(%s)", settings.LocalPrefixes), - } - } - parsedCfg, err := cfg.Parse() if err != nil { return nil, err diff --git a/pkg/golinters/errcheck/errcheck.go b/pkg/golinters/errcheck/errcheck.go index 67a1b2ca8d2d..16d9eb36c974 100644 --- a/pkg/golinters/errcheck/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -1,14 +1,9 @@ package errcheck import ( - "bufio" "cmp" "fmt" - "os" - "os/user" - "path/filepath" "regexp" - "strings" "sync" "github.com/kisielk/errcheck/errcheck" @@ -16,7 +11,6 @@ import ( "golang.org/x/tools/go/packages" "github.com/golangci/golangci-lint/pkg/config" - "github.com/golangci/golangci-lint/pkg/fsutils" "github.com/golangci/golangci-lint/pkg/goanalysis" "github.com/golangci/golangci-lint/pkg/golinters/internal" "github.com/golangci/golangci-lint/pkg/lint/linter" @@ -42,20 +36,11 @@ func New(settings *config.ErrcheckSettings) *goanalysis.Linter { []*analysis.Analyzer{analyzer}, nil, ).WithContextSetter(func(lintCtx *linter.Context) { - // copied from errcheck - checker, err := getChecker(settings) - if err != nil { - lintCtx.Log.Errorf("failed to get checker: %v", err) - return - } - + checker := getChecker(settings) checker.Tags = lintCtx.Cfg.Run.BuildTags analyzer.Run = func(pass *analysis.Pass) (any, error) { issues := runErrCheck(lintCtx, pass, checker) - if err != nil { - return nil, err - } if len(issues) == 0 { return nil, nil @@ -109,41 +94,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck return issues } -// parseIgnoreConfig was taken from errcheck in order to keep the API identical. -// https://github.com/kisielk/errcheck/blob/1787c4bee836470bf45018cfbc783650db3c6501/main.go#L25-L60 -func parseIgnoreConfig(s string) (map[string]*regexp.Regexp, error) { - if s == "" { - return nil, nil - } - - cfg := map[string]*regexp.Regexp{} - - for _, pair := range strings.Split(s, ",") { - colonIndex := strings.Index(pair, ":") - var pkg, re string - if colonIndex == -1 { - pkg = "" - re = pair - } else { - pkg = pair[:colonIndex] - re = pair[colonIndex+1:] - } - regex, err := regexp.Compile(re) - if err != nil { - return nil, err - } - cfg[pkg] = regex - } - - return cfg, nil -} - -func getChecker(errCfg *config.ErrcheckSettings) (*errcheck.Checker, error) { - ignoreConfig, err := parseIgnoreConfig(errCfg.Ignore) - if err != nil { - return nil, fmt.Errorf("failed to parse 'ignore' directive: %w", err) - } - +func getChecker(errCfg *config.ErrcheckSettings) *errcheck.Checker { checker := errcheck.Checker{ Exclusions: errcheck.Exclusions{ BlankAssignments: !errCfg.CheckAssignToBlank, @@ -156,114 +107,7 @@ func getChecker(errCfg *config.ErrcheckSettings) (*errcheck.Checker, error) { checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, errcheck.DefaultExcludedSymbols...) } - for pkg, re := range ignoreConfig { - checker.Exclusions.SymbolRegexpsByPackage[pkg] = re - } - - if errCfg.Exclude != "" { - exclude, err := readExcludeFile(errCfg.Exclude) - if err != nil { - return nil, err - } - - checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, exclude...) - } - checker.Exclusions.Symbols = append(checker.Exclusions.Symbols, errCfg.ExcludeFunctions...) - return &checker, nil -} - -func getFirstPathArg() string { - args := os.Args - - // skip all args ([golangci-lint, run/linters]) before files/dirs list - for len(args) != 0 { - if args[0] == "run" { - args = args[1:] - break - } - - args = args[1:] - } - - // find first file/dir arg - firstArg := "./..." - for _, arg := range args { - if !strings.HasPrefix(arg, "-") { - firstArg = arg - break - } - } - - return firstArg -} - -func setupConfigFileSearch(name string) []string { - if strings.HasPrefix(name, "~") { - if u, err := user.Current(); err == nil { - name = strings.Replace(name, "~", u.HomeDir, 1) - } - } - - if filepath.IsAbs(name) { - return []string{name} - } - - firstArg := getFirstPathArg() - - absStartPath, err := filepath.Abs(firstArg) - if err != nil { - absStartPath = filepath.Clean(firstArg) - } - - // start from it - var curDir string - if fsutils.IsDir(absStartPath) { - curDir = absStartPath - } else { - curDir = filepath.Dir(absStartPath) - } - - // find all dirs from it up to the root - configSearchPaths := []string{filepath.Join(".", name)} - for { - configSearchPaths = append(configSearchPaths, filepath.Join(curDir, name)) - newCurDir := filepath.Dir(curDir) - if curDir == newCurDir || newCurDir == "" { - break - } - curDir = newCurDir - } - - return configSearchPaths -} - -func readExcludeFile(name string) ([]string, error) { - var err error - var fh *os.File - - for _, path := range setupConfigFileSearch(name) { - if fh, err = os.Open(path); err == nil { - break - } - } - - if fh == nil { - return nil, fmt.Errorf("failed reading exclude file: %s: %w", name, err) - } - defer func() { _ = fh.Close() }() - - scanner := bufio.NewScanner(fh) - - var excludes []string - for scanner.Scan() { - excludes = append(excludes, scanner.Text()) - } - - if err := scanner.Err(); err != nil { - return nil, fmt.Errorf("failed scanning file: %s: %w", name, err) - } - - return excludes, nil + return &checker } diff --git a/pkg/golinters/godot/godot.go b/pkg/golinters/godot/godot.go index 3194b3d3ac13..44bb54cfb53d 100644 --- a/pkg/golinters/godot/godot.go +++ b/pkg/golinters/godot/godot.go @@ -22,11 +22,6 @@ func New(settings *config.GodotSettings) *goanalysis.Linter { Period: settings.Period, Capital: settings.Capital, } - - // Convert deprecated setting - if settings.CheckAll != nil && *settings.CheckAll { - dotSettings.Scope = godot.AllScope - } } dotSettings.Scope = cmp.Or(dotSettings.Scope, godot.DeclScope) diff --git a/pkg/golinters/govet/govet.go b/pkg/golinters/govet/govet.go index b970e4039271..7518f10f00af 100644 --- a/pkg/golinters/govet/govet.go +++ b/pkg/golinters/govet/govet.go @@ -189,11 +189,6 @@ func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers return false } - // Keeping for backward compatibility. - if cfg.CheckShadowing != nil && *cfg.CheckShadowing && name == shadow.Analyzer.Name { - return true - } - switch { case cfg.EnableAll: return !slices.Contains(cfg.Disable, name) diff --git a/pkg/golinters/usestdlibvars/usestdlibvars.go b/pkg/golinters/usestdlibvars/usestdlibvars.go index 00f7d9742a56..88488bc7fd2c 100644 --- a/pkg/golinters/usestdlibvars/usestdlibvars.go +++ b/pkg/golinters/usestdlibvars/usestdlibvars.go @@ -18,10 +18,10 @@ func New(settings *config.UseStdlibVarsSettings) *goanalysis.Linter { analyzer.CryptoHashFlag: settings.CryptoHash, analyzer.HTTPMethodFlag: settings.HTTPMethod, analyzer.HTTPStatusCodeFlag: settings.HTTPStatusCode, - analyzer.OSDevNullFlag: settings.OSDevNull != nil && *settings.OSDevNull, + analyzer.OSDevNullFlag: false, // Noop because the linter ignore it. analyzer.RPCDefaultPathFlag: settings.DefaultRPCPath, analyzer.SQLIsolationLevelFlag: settings.SQLIsolationLevel, - analyzer.SyslogPriorityFlag: settings.SyslogPriority != nil && *settings.SyslogPriority, + analyzer.SyslogPriorityFlag: false, // Noop because the linter ignore it. analyzer.TimeLayoutFlag: settings.TimeLayout, analyzer.TimeMonthFlag: settings.TimeMonth, analyzer.TimeWeekdayFlag: settings.TimeWeekday, From b9c06e9268e9aacd9684cec2bcff62473c510be6 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 22:31:35 +0100 Subject: [PATCH 3/5] chore: remove deprecated linters --- go.mod | 1 - go.sum | 2 - .../nolintlint/testdata/nolintlint_unused.go | 4 +- pkg/golinters/tenv/tenv.go | 29 ------- pkg/golinters/tenv/tenv_integration_test.go | 11 --- pkg/golinters/tenv/testdata/tenv_all.go | 48 ---------- pkg/golinters/tenv/testdata/tenv_all.yml | 5 -- pkg/golinters/tenv/testdata/tenv_all_test.go | 48 ---------- pkg/golinters/tenv/testdata/tenv_default.go | 47 ---------- .../tenv/testdata/tenv_default_test.go | 47 ---------- pkg/lint/lintersdb/builder_linter.go | 87 ------------------- pkg/result/processors/nolint_filter_test.go | 24 ++--- .../testdata/nolint_filter/unused.go | 4 +- test/testdata/default_exclude.go | 8 +- 14 files changed, 20 insertions(+), 345 deletions(-) delete mode 100644 pkg/golinters/tenv/tenv.go delete mode 100644 pkg/golinters/tenv/tenv_integration_test.go delete mode 100644 pkg/golinters/tenv/testdata/tenv_all.go delete mode 100644 pkg/golinters/tenv/testdata/tenv_all.yml delete mode 100644 pkg/golinters/tenv/testdata/tenv_all_test.go delete mode 100644 pkg/golinters/tenv/testdata/tenv_default.go delete mode 100644 pkg/golinters/tenv/testdata/tenv_default_test.go diff --git a/go.mod b/go.mod index 899527862a39..67714b0b08c3 100644 --- a/go.mod +++ b/go.mod @@ -98,7 +98,6 @@ require ( github.com/shirou/gopsutil/v4 v4.25.1 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 - github.com/sivchari/tenv v1.12.1 github.com/sonatard/noctx v0.1.0 github.com/sourcegraph/go-diff v0.7.0 github.com/spf13/cobra v1.9.0 diff --git a/go.sum b/go.sum index a9cdc32f98e0..d4ccf6da8def 100644 --- a/go.sum +++ b/go.sum @@ -511,8 +511,6 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sivchari/tenv v1.12.1 h1:+E0QzjktdnExv/wwsnnyk4oqZBUfuh89YMQT1cyuvSY= -github.com/sivchari/tenv v1.12.1/go.mod h1:1LjSOUCc25snIr5n3DtGGrENhX3LuWefcplwVGC24mw= github.com/sonatard/noctx v0.1.0 h1:JjqOc2WN16ISWAjAk8M5ej0RfExEXtkEyExl2hLW+OM= github.com/sonatard/noctx v0.1.0/go.mod h1:0RvBxqY8D4j9cTTTWE8ylt2vqj2EPI8fHmrxHdsaZ2c= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= diff --git a/pkg/golinters/nolintlint/testdata/nolintlint_unused.go b/pkg/golinters/nolintlint/testdata/nolintlint_unused.go index 6984f190d394..53d3137c8daa 100644 --- a/pkg/golinters/nolintlint/testdata/nolintlint_unused.go +++ b/pkg/golinters/nolintlint/testdata/nolintlint_unused.go @@ -1,4 +1,4 @@ -//golangcitest:args -Enolintlint -Evarcheck +//golangcitest:args -Enolintlint -Emisspell //golangcitest:expected_linter nolintlint //golangcitest:config_path nolintlint_unused.yml package testdata @@ -7,6 +7,6 @@ import "fmt" func Foo() { fmt.Println("unused") //nolint:all // want "directive `//nolint .*` is unused" - fmt.Println("unused,specific") //nolint:varcheck // want "directive `//nolint:varcheck .*` is unused for linter varcheck" + fmt.Println("unused,specific") //nolint:misspell // want "directive `//nolint:misspell .*` is unused for linter misspell" fmt.Println("not run") //nolint:unparam // unparam is not run so this is ok } diff --git a/pkg/golinters/tenv/tenv.go b/pkg/golinters/tenv/tenv.go deleted file mode 100644 index 2fc247fab89b..000000000000 --- a/pkg/golinters/tenv/tenv.go +++ /dev/null @@ -1,29 +0,0 @@ -package tenv - -import ( - "github.com/sivchari/tenv" - "golang.org/x/tools/go/analysis" - - "github.com/golangci/golangci-lint/pkg/config" - "github.com/golangci/golangci-lint/pkg/goanalysis" -) - -func New(settings *config.TenvSettings) *goanalysis.Linter { - a := tenv.Analyzer - - var cfg map[string]map[string]any - if settings != nil { - cfg = map[string]map[string]any{ - a.Name: { - tenv.A: settings.All, - }, - } - } - - return goanalysis.NewLinter( - a.Name, - a.Doc, - []*analysis.Analyzer{a}, - cfg, - ).WithLoadMode(goanalysis.LoadModeTypesInfo) -} diff --git a/pkg/golinters/tenv/tenv_integration_test.go b/pkg/golinters/tenv/tenv_integration_test.go deleted file mode 100644 index d7fdff3c0080..000000000000 --- a/pkg/golinters/tenv/tenv_integration_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package tenv - -import ( - "testing" - - "github.com/golangci/golangci-lint/test/testshared/integration" -) - -func TestFromTestdata(t *testing.T) { - integration.RunTestdata(t) -} diff --git a/pkg/golinters/tenv/testdata/tenv_all.go b/pkg/golinters/tenv/testdata/tenv_all.go deleted file mode 100644 index 986b2f5daee4..000000000000 --- a/pkg/golinters/tenv/testdata/tenv_all.go +++ /dev/null @@ -1,48 +0,0 @@ -//golangcitest:args -Etenv -//golangcitest:config_path testdata/tenv_all.yml -package testdata - -import ( - "os" - "testing" -) - -var ( - e = os.Setenv("a", "b") // never seen -) - -func setup() { - os.Setenv("a", "b") // never seen - err := os.Setenv("a", "b") // never seen - _ = err - if err := os.Setenv("a", "b"); err != nil { // never seen - _ = err - } -} - -func TestF(t *testing.T) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - } -} - -func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - } -} - -func testTB(tb testing.TB) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - } -} diff --git a/pkg/golinters/tenv/testdata/tenv_all.yml b/pkg/golinters/tenv/testdata/tenv_all.yml deleted file mode 100644 index a3a0de572ec7..000000000000 --- a/pkg/golinters/tenv/testdata/tenv_all.yml +++ /dev/null @@ -1,5 +0,0 @@ -version: "2" - -linters-settings: - tenv: - all: true diff --git a/pkg/golinters/tenv/testdata/tenv_all_test.go b/pkg/golinters/tenv/testdata/tenv_all_test.go deleted file mode 100644 index bd5fc97974b9..000000000000 --- a/pkg/golinters/tenv/testdata/tenv_all_test.go +++ /dev/null @@ -1,48 +0,0 @@ -//golangcitest:args -Etenv -//golangcitest:config_path testdata/tenv_all.yml -package testdata - -import ( - "os" - "testing" -) - -var ( - e = os.Setenv("a", "b") // never seen -) - -func setup() { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `testing\\.Setenv\\(\\)` in setup" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `testing\\.Setenv\\(\\)` in setup" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `testing\\.Setenv\\(\\)` in setup" - _ = err - } -} - -func TestF(t *testing.T) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - } -} - -func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - } -} - -func testTB(tb testing.TB) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - } -} diff --git a/pkg/golinters/tenv/testdata/tenv_default.go b/pkg/golinters/tenv/testdata/tenv_default.go deleted file mode 100644 index a5e0c44b1475..000000000000 --- a/pkg/golinters/tenv/testdata/tenv_default.go +++ /dev/null @@ -1,47 +0,0 @@ -//golangcitest:args -Etenv -package testdata - -import ( - "os" - "testing" -) - -var ( - e = os.Setenv("a", "b") // never seen -) - -func setup() { - os.Setenv("a", "b") // never seen - err := os.Setenv("a", "b") // never seen - _ = err - if err := os.Setenv("a", "b"); err != nil { // never seen - _ = err - } -} - -func TestF(t *testing.T) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - } -} - -func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - } -} - -func testTB(tb testing.TB) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - } -} diff --git a/pkg/golinters/tenv/testdata/tenv_default_test.go b/pkg/golinters/tenv/testdata/tenv_default_test.go deleted file mode 100644 index 76f358fd6e68..000000000000 --- a/pkg/golinters/tenv/testdata/tenv_default_test.go +++ /dev/null @@ -1,47 +0,0 @@ -//golangcitest:args -Etenv -package testdata - -import ( - "os" - "testing" -) - -var ( - e = os.Setenv("a", "b") // never seen -) - -func setup() { - os.Setenv("a", "b") // OK - err := os.Setenv("a", "b") // OK - _ = err - if err := os.Setenv("a", "b"); err != nil { // OK - _ = err - } -} - -func TestF(t *testing.T) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in TestF" - _ = err - } -} - -func BenchmarkF(b *testing.B) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `b\\.Setenv\\(\\)` in BenchmarkF" - _ = err - } -} - -func testTB(tb testing.TB) { - os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `tb\\.Setenv\\(\\)` in testTB" - _ = err - } -} diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 7c93692a0be7..25469d703cd4 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -97,7 +97,6 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/stylecheck" "github.com/golangci/golangci-lint/pkg/golinters/tagalign" "github.com/golangci/golangci-lint/pkg/golinters/tagliatelle" - "github.com/golangci/golangci-lint/pkg/golinters/tenv" "github.com/golangci/golangci-lint/pkg/golinters/testableexamples" "github.com/golangci/golangci-lint/pkg/golinters/testifylint" "github.com/golangci/golangci-lint/pkg/golinters/testpackage" @@ -195,12 +194,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetStyle). WithURL("https://gitlab.com/bosi/decorder"), - linter.NewConfig(linter.NewNoopDeprecated("deadcode", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetUnused). - WithURL("https://github.com/remyoudompheng/go-misc/tree/HEAD/deadcode"). - DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard, cfg.GetBasePath())). WithSince("v1.4.0"). WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). @@ -254,37 +247,18 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://github.com/polyfloyd/go-errorlint"), - linter.NewConfig(linter.NewNoopDeprecated("execinquery", cfg, linter.DeprecationError)). - WithSince("v1.46.0"). - WithPresets(linter.PresetSQL). - WithURL("https://github.com/1uf3/execinquery"). - DeprecatedError("The repository of the linter has been archived by the owner.", "v1.58.0", ""), - linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)). WithSince(" v1.28.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/nishanths/exhaustive"), - linter.NewConfig(linter.NewNoopDeprecated("exhaustivestruct", cfg, linter.DeprecationError)). - WithSince("v1.32.0"). - WithPresets(linter.PresetStyle, linter.PresetTest). - WithURL("https://github.com/mbilski/exhaustivestruct"). - DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.46.0", "exhaustruct"), - linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)). WithSince("v1.46.0"). WithPresets(linter.PresetStyle, linter.PresetTest). WithLoadForGoAnalysis(). WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"), - linter.NewConfig(linter.NewNoopDeprecated("exportloopref", cfg, linter.DeprecationError)). - WithSince("v1.28.0"). - WithPresets(linter.PresetBugs). - WithLoadForGoAnalysis(). - WithURL("https://github.com/kyoh86/exportloopref"). - DeprecatedError("Since Go1.22 (loopvar) this linter is no longer relevant.", "v1.60.2", "copyloopvar"), - linter.NewConfig(exptostd.New()). WithSince("v1.63.0"). WithPresets(linter.PresetStyle). @@ -425,23 +399,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"), - linter.NewConfig(linter.NewNoopDeprecated("golint", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetStyle). - WithURL("https://github.com/golang/lint"). - DeprecatedError("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"), - linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)). WithSince("v1.22.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/tommy-muehle/go-mnd"), - linter.NewConfig(linter.NewNoopDeprecated("gomnd", cfg, linter.DeprecationError)). - WithSince("v1.22.0"). - WithPresets(linter.PresetStyle). - WithURL("https://github.com/tommy-muehle/go-mnd"). - DeprecatedError("The linter has been renamed.", "v1.58.0", "mnd"), - linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)). WithSince("v1.39.0"). WithPresets(linter.PresetStyle, linter.PresetModule). @@ -493,12 +455,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetStyle). WithURL("https://github.com/leonklingele/grouper"), - linter.NewConfig(linter.NewNoopDeprecated("ifshort", cfg, linter.DeprecationError)). - WithSince("v1.36.0"). - WithPresets(linter.PresetStyle). - WithURL("https://github.com/esimonov/ifshort"). - DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.0", ""), - linter.NewConfig(iface.New(&cfg.LintersSettings.Iface)). WithSince("v1.62.0"). WithLoadForGoAnalysis(). @@ -529,12 +485,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetStyle). WithURL("https://github.com/sashamelentyev/interfacebloat"), - linter.NewConfig(linter.NewNoopDeprecated("interfacer", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetStyle). - WithURL("https://github.com/mvdan/interfacer"). - DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", ""), - linter.NewConfig(intrange.New()). WithSince("v1.57.0"). WithLoadForGoAnalysis(). @@ -571,12 +521,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/ashanbrown/makezero"), - linter.NewConfig(linter.NewNoopDeprecated("maligned", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetPerformance). - WithURL("https://github.com/mdempsky/maligned"). - DeprecatedError("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"), - linter.NewConfig(mirror.New()). WithSince("v1.53.0"). WithPresets(linter.PresetStyle). @@ -643,12 +587,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetStyle). WithURL("https://github.com/firefart/nonamedreturns"), - linter.NewConfig(linter.NewNoopDeprecated("nosnakecase", cfg, linter.DeprecationError)). - WithSince("v1.47.0"). - WithPresets(linter.PresetStyle). - WithURL("https://github.com/sivchari/nosnakecase"). - DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.48.1", "revive 'var-naming'"), - linter.NewConfig(nosprintfhostport.New()). WithSince("v1.46.0"). WithPresets(linter.PresetStyle). @@ -720,12 +658,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetStyle). WithURL("https://github.com/go-simpler/sloglint"), - linter.NewConfig(linter.NewNoopDeprecated("scopelint", cfg, linter.DeprecationError)). - WithSince("v1.12.0"). - WithPresets(linter.PresetBugs). - WithURL("https://github.com/kyoh86/scopelint"). - DeprecatedError("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"), - linter.NewConfig(sqlclosecheck.New()). WithSince("v1.28.0"). WithPresets(linter.PresetBugs, linter.PresetSQL). @@ -747,12 +679,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://staticcheck.dev/"), - linter.NewConfig(linter.NewNoopDeprecated("structcheck", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetUnused). - WithURL("https://github.com/opennota/check"). - DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)). WithSince("v1.20.0"). WithLoadForGoAnalysis(). @@ -772,13 +698,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/ldez/tagliatelle"), - linter.NewConfig(tenv.New(&cfg.LintersSettings.Tenv)). - WithSince("v1.43.0"). - WithPresets(linter.PresetTest). - WithLoadForGoAnalysis(). - WithURL("https://github.com/sivchari/tenv"). - DeprecatedWarning("Duplicate feature another linter.", "v1.64.0", "usetesting"), - linter.NewConfig(testableexamples.New()). WithSince("v1.50.0"). WithPresets(linter.PresetTest). @@ -848,12 +767,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAutoFix(). WithURL("https://github.com/ldez/usetesting"), - linter.NewConfig(linter.NewNoopDeprecated("varcheck", cfg, linter.DeprecationError)). - WithSince("v1.0.0"). - WithPresets(linter.PresetUnused). - WithURL("https://github.com/opennota/check"). - DeprecatedError("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)). WithSince("v1.43.0"). WithPresets(linter.PresetStyle). diff --git a/pkg/result/processors/nolint_filter_test.go b/pkg/result/processors/nolint_filter_test.go index 5495620485b9..2cf4c761c15d 100644 --- a/pkg/result/processors/nolint_filter_test.go +++ b/pkg/result/processors/nolint_filter_test.go @@ -295,43 +295,43 @@ func TestNolintFilter_Process_unused(t *testing.T) { } // the issue below is the nolintlint issue that would be generated for the test file - nolintlintIssueVarcheck := result.Issue{ + nolintlintIssueMisspell := result.Issue{ Pos: token.Position{ Filename: fileName, Line: 3, }, FromLinter: nolintlint.LinterName, ExpectNoLint: true, - ExpectedNoLintLinter: "varcheck", + ExpectedNoLintLinter: "misspell", } // the issue below is another nolintlint issue that would be generated for the test file - nolintlintIssueVarcheckUnusedOK := result.Issue{ + nolintlintIssueMisspellUnusedOK := result.Issue{ Pos: token.Position{ Filename: fileName, Line: 5, }, FromLinter: nolintlint.LinterName, ExpectNoLint: true, - ExpectedNoLintLinter: "varcheck", + ExpectedNoLintLinter: "misspell", } t.Run("when an issue does not occur, it is not removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "varcheck"}) + p := createProcessor(t, log, []string{"nolintlint", "misspell"}) defer p.Finish() - processAssertSame(t, p, nolintlintIssueVarcheck) + processAssertSame(t, p, nolintlintIssueMisspell) }) t.Run("when an issue does not occur but nolintlint is nolinted, it is removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "varcheck"}) + p := createProcessor(t, log, []string{"nolintlint", "misspell"}) defer p.Finish() - processAssertEmpty(t, p, nolintlintIssueVarcheckUnusedOK) + processAssertEmpty(t, p, nolintlintIssueMisspellUnusedOK) }) t.Run("when an issue occurs, it is removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "varcheck"}) + p := createProcessor(t, log, []string{"nolintlint", "misspell"}) defer p.Finish() processAssertEmpty(t, p, []result.Issue{{ @@ -339,8 +339,8 @@ func TestNolintFilter_Process_unused(t *testing.T) { Filename: fileName, Line: 3, }, - FromLinter: "varcheck", - }, nolintlintIssueVarcheck}...) + FromLinter: "misspell", + }, nolintlintIssueMisspell}...) }) t.Run("when a linter is not enabled, it is removed from the nolintlint unused issues", func(t *testing.T) { @@ -358,6 +358,6 @@ func TestNolintFilter_Process_unused(t *testing.T) { p := NewNolintFilter(log, dbManager, enabledLintersMap) defer p.Finish() - processAssertEmpty(t, p, nolintlintIssueVarcheck) + processAssertEmpty(t, p, nolintlintIssueMisspell) }) } diff --git a/pkg/result/processors/testdata/nolint_filter/unused.go b/pkg/result/processors/testdata/nolint_filter/unused.go index 77bd95b6a2ce..a14d99df4e7e 100644 --- a/pkg/result/processors/testdata/nolint_filter/unused.go +++ b/pkg/result/processors/testdata/nolint_filter/unused.go @@ -1,5 +1,5 @@ package nolint_filter -var nolintVarcheck int //nolint:varcheck +var nolintMisspell int //nolint:misspell -var nolintVarcheckUnusedOK int //nolint:varcheck,nolintlint +var nolintMisspellUnusedOK int //nolint:misspell,nolintlint diff --git a/test/testdata/default_exclude.go b/test/testdata/default_exclude.go index 7c9d00607554..c97eb7fbd414 100644 --- a/test/testdata/default_exclude.go +++ b/test/testdata/default_exclude.go @@ -1,18 +1,18 @@ -//golangcitest:args -Estylecheck,golint --internal-cmd-test +//golangcitest:args -Estylecheck,revive --internal-cmd-test //golangcitest:config_path testdata/configs/default_exclude.yml /*Package testdata ...*/ package testdata -// InvalidFuncComment, both golint and stylecheck will complain about this, // want stylecheck:`ST1020: comment on exported function ExportedFunc1 should be of the form "ExportedFunc1 ..."` -// if include EXC0011, only the warning from golint will be ignored. +// InvalidFuncComment, both revive and stylecheck will complain about this, // want stylecheck:`ST1020: comment on exported function ExportedFunc1 should be of the form "ExportedFunc1 ..."` +// if include EXC0011, only the warning from revive will be ignored. // And only the warning from stylecheck will start with "ST1020". func ExportedFunc1() { } // InvalidFuncComment // want stylecheck:`ST1020: comment on exported function ExportedFunc2 should be of the form "ExportedFunc2 ..."` // -//nolint:golint +//nolint:revive func ExportedFunc2() { } From 478195cc846f781be8fb7b802cb616fd9ea64ed9 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 18 Feb 2025 22:52:43 +0100 Subject: [PATCH 4/5] docs: remove deprecated linter names --- .golangci.next.reference.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 7bacc9d84b63..63cfb2a60dd9 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -238,20 +238,6 @@ linters: - wrapcheck - wsl - zerologlint - - deadcode # Deprecated - - execinquery # Deprecated - - exhaustivestruct # Deprecated - - exportloopref # Deprecated - - golint # Deprecated - - gomnd # Deprecated - - ifshort # Deprecated - - interfacer # Deprecated - - maligned # Deprecated - - nosnakecase # Deprecated - - scopelint # Deprecated - - structcheck # Deprecated - - tenv # Deprecated - - varcheck # Deprecated # Enable presets. # https://golangci-lint.run/usage/linters From df61b73c671106682fc5af4752541d459f0a4758 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 19 Feb 2025 20:11:34 +0100 Subject: [PATCH 5/5] tests: change linter names order --- pkg/result/processors/nolint_filter_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/result/processors/nolint_filter_test.go b/pkg/result/processors/nolint_filter_test.go index 2cf4c761c15d..66263b9eca12 100644 --- a/pkg/result/processors/nolint_filter_test.go +++ b/pkg/result/processors/nolint_filter_test.go @@ -317,21 +317,21 @@ func TestNolintFilter_Process_unused(t *testing.T) { } t.Run("when an issue does not occur, it is not removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "misspell"}) + p := createProcessor(t, log, []string{"misspell", "nolintlint"}) defer p.Finish() processAssertSame(t, p, nolintlintIssueMisspell) }) t.Run("when an issue does not occur but nolintlint is nolinted, it is removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "misspell"}) + p := createProcessor(t, log, []string{"misspell", "nolintlint"}) defer p.Finish() processAssertEmpty(t, p, nolintlintIssueMisspellUnusedOK) }) t.Run("when an issue occurs, it is removed from the nolintlint issues", func(t *testing.T) { - p := createProcessor(t, log, []string{"nolintlint", "misspell"}) + p := createProcessor(t, log, []string{"misspell", "nolintlint"}) defer p.Finish() processAssertEmpty(t, p, []result.Issue{{