Skip to content

feat: remove deprecated elements #5450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4260,7 +4260,7 @@
"type": "boolean",
"default": false
},
"default": {
"presets": {
"type": "array",
"items": {
"enum": [
Expand Down
6 changes: 1 addition & 5 deletions pkg/config/formatters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/linters_exclusions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
29 changes: 0 additions & 29 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
133 changes: 6 additions & 127 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 0 additions & 10 deletions pkg/config/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 0 additions & 9 deletions pkg/goformatters/gci/gci.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gci

import (
"context"
"fmt"

gcicfg "github.com/daixiang0/gci/pkg/config"
"github.com/daixiang0/gci/pkg/gci"
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading