Skip to content

Commit fab6467

Browse files
authored
feat: remove deprecated elements (#5450)
1 parent 7611c76 commit fab6467

28 files changed

+34
-717
lines changed

.golangci.next.reference.yml

-14
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,6 @@ linters:
238238
- wrapcheck
239239
- wsl
240240
- zerologlint
241-
- deadcode # Deprecated
242-
- execinquery # Deprecated
243-
- exhaustivestruct # Deprecated
244-
- exportloopref # Deprecated
245-
- golint # Deprecated
246-
- gomnd # Deprecated
247-
- ifshort # Deprecated
248-
- interfacer # Deprecated
249-
- maligned # Deprecated
250-
- nosnakecase # Deprecated
251-
- scopelint # Deprecated
252-
- structcheck # Deprecated
253-
- tenv # Deprecated
254-
- varcheck # Deprecated
255241

256242
# Enable presets.
257243
# https://golangci-lint.run/usage/linters

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ require (
9898
github.com/shirou/gopsutil/v4 v4.25.1
9999
github.com/sirupsen/logrus v1.9.3
100100
github.com/sivchari/containedctx v1.0.3
101-
github.com/sivchari/tenv v1.12.1
102101
github.com/sonatard/noctx v0.1.0
103102
github.com/sourcegraph/go-diff v0.7.0
104103
github.com/spf13/cobra v1.9.0

go.sum

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4260,7 +4260,7 @@
42604260
"type": "boolean",
42614261
"default": false
42624262
},
4263-
"default": {
4263+
"presets": {
42644264
"type": "array",
42654265
"items": {
42664266
"enum": [

pkg/config/formatters_settings.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ type GciSettings struct {
3131
SkipGenerated bool `mapstructure:"skip-generated"`
3232
CustomOrder bool `mapstructure:"custom-order"`
3333
NoLexOrder bool `mapstructure:"no-lex-order"`
34-
35-
// Deprecated: use Sections instead.
36-
LocalPrefixes string `mapstructure:"local-prefixes"`
3734
}
3835

3936
type GoFmtSettings struct {
@@ -50,8 +47,7 @@ type GoFumptSettings struct {
5047
ModulePath string `mapstructure:"module-path"`
5148
ExtraRules bool `mapstructure:"extra-rules"`
5249

53-
// Deprecated: use the global `run.go` instead.
54-
LangVersion string `mapstructure:"lang-version"`
50+
LangVersion string `mapstructure:"-"`
5551
}
5652

5753
type GoImportsSettings struct {

pkg/config/issues.go

-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ type Issues struct {
124124
Diff bool `mapstructure:"new"`
125125

126126
NeedFix bool `mapstructure:"fix"`
127-
128-
ExcludeGeneratedStrict *bool `mapstructure:"exclude-generated-strict"` // Deprecated: use ExcludeGenerated instead.
129127
}
130128

131129
func (i *Issues) Validate() error {

pkg/config/linters_exclusions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const excludeRuleMinConditionsCount = 2
2323
type LinterExclusions struct {
2424
Generated string `mapstructure:"generated"`
2525
WarnUnused bool `mapstructure:"warn-unused"`
26-
Presets []string `mapstructure:"preset"`
26+
Presets []string `mapstructure:"presets"`
2727
Rules []ExcludeRule `mapstructure:"rules"`
2828
Paths []string `mapstructure:"paths"`
2929
PathsExcept []string `mapstructure:"paths-except"`

pkg/config/linters_settings.go

-29
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,6 @@ type BiDiChkSettings struct {
324324

325325
type CopyLoopVarSettings struct {
326326
CheckAlias bool `mapstructure:"check-alias"`
327-
328-
// Deprecated: use CheckAlias
329-
IgnoreAlias *bool `mapstructure:"ignore-alias"`
330327
}
331328

332329
type Cyclop struct {
@@ -380,12 +377,6 @@ type ErrcheckSettings struct {
380377
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
381378
CheckAssignToBlank bool `mapstructure:"check-blank"`
382379
ExcludeFunctions []string `mapstructure:"exclude-functions"`
383-
384-
// Deprecated: use ExcludeFunctions instead
385-
Exclude string `mapstructure:"exclude"`
386-
387-
// Deprecated: use ExcludeFunctions instead
388-
Ignore string `mapstructure:"ignore"`
389380
}
390381

391382
type ErrChkJSONSettings struct {
@@ -534,9 +525,6 @@ type GodotSettings struct {
534525
Exclude []string `mapstructure:"exclude"`
535526
Capital bool `mapstructure:"capital"`
536527
Period bool `mapstructure:"period"`
537-
538-
// Deprecated: use Scope instead
539-
CheckAll *bool `mapstructure:"check-all"`
540528
}
541529

542530
type GodoxSettings struct {
@@ -605,9 +593,6 @@ type GovetSettings struct {
605593
DisableAll bool `mapstructure:"disable-all"`
606594

607595
Settings map[string]map[string]any
608-
609-
// Deprecated: the linter should be enabled inside Enable.
610-
CheckShadowing *bool `mapstructure:"check-shadowing"`
611596
}
612597

613598
func (cfg *GovetSettings) Validate() error {
@@ -834,9 +819,6 @@ type SlogLintSettings struct {
834819
KeyNamingCase string `mapstructure:"key-naming-case"`
835820
ForbiddenKeys []string `mapstructure:"forbidden-keys"`
836821
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
837-
838-
// Deprecated: use Context instead.
839-
ContextOnly *bool `mapstructure:"context-only"`
840822
}
841823

842824
type SpancheckSettings struct {
@@ -850,9 +832,6 @@ type StaticCheckSettings struct {
850832
Initialisms []string `mapstructure:"initialisms"` // only for stylecheck
851833
DotImportWhitelist []string `mapstructure:"dot-import-whitelist"` // only for stylecheck
852834
HTTPStatusCodeWhitelist []string `mapstructure:"http-status-code-whitelist"` // only for stylecheck
853-
854-
// Deprecated: use the global `run.go` instead.
855-
GoVersion string `mapstructure:"go"`
856835
}
857836

858837
func (s *StaticCheckSettings) HasConfiguration() bool {
@@ -959,11 +938,6 @@ type UseStdlibVarsSettings struct {
959938
SQLIsolationLevel bool `mapstructure:"sql-isolation-level"`
960939
TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"`
961940
ConstantKind bool `mapstructure:"constant-kind"`
962-
963-
// Deprecated
964-
OSDevNull *bool `mapstructure:"os-dev-null"`
965-
// Deprecated
966-
SyslogPriority *bool `mapstructure:"syslog-priority"`
967941
}
968942

969943
type UseTestingSettings struct {
@@ -993,9 +967,6 @@ type UnusedSettings struct {
993967
ParametersAreUsed bool `mapstructure:"parameters-are-used"`
994968
LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"`
995969
GeneratedIsUsed bool `mapstructure:"generated-is-used"`
996-
997-
// Deprecated
998-
ExportedIsUsed *bool `mapstructure:"exported-is-used"`
999970
}
1000971

1001972
type VarnamelenSettings struct {

pkg/config/loader.go

+6-127
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ func (l *Loader) applyStringSliceHack() {
301301
l.appendStringSlice("build-tags", &l.cfg.Run.BuildTags)
302302
l.appendStringSlice("exclude", &l.cfg.Issues.ExcludePatterns)
303303

304-
l.appendStringSlice("skip-dirs", &l.cfg.Run.SkipDirs)
305-
l.appendStringSlice("skip-files", &l.cfg.Run.SkipFiles)
306304
l.appendStringSlice("exclude-dirs", &l.cfg.Issues.ExcludeDirs)
307305
l.appendStringSlice("exclude-files", &l.cfg.Issues.ExcludeFiles)
308306
}
@@ -323,8 +321,8 @@ func (l *Loader) handleGoVersion() {
323321

324322
l.cfg.LintersSettings.ParallelTest.Go = l.cfg.Run.Go
325323

326-
l.cfg.LintersSettings.GoFumpt.LangVersion = cmp.Or(l.cfg.LintersSettings.GoFumpt.LangVersion, l.cfg.Run.Go)
327-
l.cfg.Formatters.Settings.GoFumpt.LangVersion = cmp.Or(l.cfg.Formatters.Settings.GoFumpt.LangVersion, l.cfg.Run.Go)
324+
l.cfg.LintersSettings.GoFumpt.LangVersion = l.cfg.Run.Go
325+
l.cfg.Formatters.Settings.GoFumpt.LangVersion = l.cfg.Run.Go
328326

329327
trimmedGoVersion := goutil.TrimGoVersion(l.cfg.Run.Go)
330328

@@ -340,123 +338,13 @@ func (l *Loader) handleDeprecation() error {
340338
return nil
341339
}
342340

343-
// Deprecated since v1.57.0
344-
if len(l.cfg.Run.SkipFiles) > 0 {
345-
l.log.Warnf("The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`.")
346-
l.cfg.Issues.ExcludeFiles = l.cfg.Run.SkipFiles
347-
}
348-
349-
// Deprecated since v1.57.0
350-
if len(l.cfg.Run.SkipDirs) > 0 {
351-
l.log.Warnf("The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`.")
352-
l.cfg.Issues.ExcludeDirs = l.cfg.Run.SkipDirs
353-
}
354-
355-
// Deprecated since v1.57.0
356-
if l.cfg.Run.UseDefaultSkipDirs != nil {
357-
l.log.Warnf("The configuration option `run.skip-dirs-use-default` is deprecated, please use `issues.exclude-dirs-use-default`.")
358-
l.cfg.Issues.UseDefaultExcludeDirs = *l.cfg.Run.UseDefaultSkipDirs
359-
}
360-
361-
// Deprecated since v1.57.0
362-
if l.cfg.Run.ShowStats != nil {
363-
l.log.Warnf("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
364-
l.cfg.Output.ShowStats = *l.cfg.Run.ShowStats
365-
}
366-
367-
// Deprecated since v1.63.0
368-
if l.cfg.Output.UniqByLine != nil {
369-
l.log.Warnf("The configuration option `output.uniq-by-line` is deprecated, please use `issues.uniq-by-line`")
370-
l.cfg.Issues.UniqByLine = *l.cfg.Output.UniqByLine
371-
}
372-
373-
// Deprecated since v1.59.0
374-
if l.cfg.Issues.ExcludeGeneratedStrict != nil {
375-
l.log.Warnf("The configuration option `issues.exclude-generated-strict` is deprecated, please use `issues.exclude-generated`")
376-
if !*l.cfg.Issues.ExcludeGeneratedStrict {
377-
l.cfg.Issues.ExcludeGenerated = "strict" // Don't use the constants to avoid cyclic dependencies.
378-
}
379-
}
380-
381341
l.handleLinterOptionDeprecations()
382342

383343
return nil
384344
}
385345

386-
func (l *Loader) handleLinterOptionDeprecations() {
387-
// Deprecated since v1.57.0,
388-
// but it was unofficially deprecated since v1.19 (2019) (https://github.com/golangci/golangci-lint/pull/697).
389-
if l.cfg.LintersSettings.Govet.CheckShadowing != nil {
390-
l.log.Warnf("The configuration option `linters.govet.check-shadowing` is deprecated. " +
391-
"Please enable `shadow` instead, if you are not using `enable-all`.")
392-
}
393-
394-
if l.cfg.LintersSettings.CopyLoopVar.IgnoreAlias != nil {
395-
l.log.Warnf("The configuration option `linters.copyloopvar.ignore-alias` is deprecated and ignored," +
396-
"please use `linters.copyloopvar.check-alias`.")
397-
}
398-
399-
// Deprecated since v1.42.0.
400-
if l.cfg.LintersSettings.Errcheck.Exclude != "" {
401-
l.log.Warnf("The configuration option `linters.errcheck.exclude` is deprecated, please use `linters.errcheck.exclude-functions`.")
402-
}
403-
404-
// Deprecated since v1.59.0,
405-
// but it was unofficially deprecated since v1.13 (2018) (https://github.com/golangci/golangci-lint/pull/332).
406-
if l.cfg.LintersSettings.Errcheck.Ignore != "" {
407-
l.log.Warnf("The configuration option `linters.errcheck.ignore` is deprecated, please use `linters.errcheck.exclude-functions`.")
408-
}
409-
410-
// Deprecated since v1.44.0.
411-
if l.cfg.LintersSettings.Gci.LocalPrefixes != "" {
412-
l.log.Warnf("The configuration option `linters.gci.local-prefixes` is deprecated, please use `prefix()` inside `linters.gci.sections`.")
413-
}
414-
415-
// Deprecated since v1.33.0.
416-
if l.cfg.LintersSettings.Godot.CheckAll != nil {
417-
l.log.Warnf("The configuration option `linters.godot.check-all` is deprecated, please use `linters.godot.scope: all`.")
418-
}
419-
420-
// Deprecated since v1.47.0
421-
if l.cfg.LintersSettings.GoFumpt.LangVersion != "" {
422-
l.log.Warnf("The configuration option `linters.gofumpt.lang-version` is deprecated, please use global `run.go`.")
423-
}
424-
425-
// Deprecated since v1.47.0
426-
if l.cfg.LintersSettings.Staticcheck.GoVersion != "" {
427-
l.log.Warnf("The configuration option `linters.staticcheck.go` is deprecated, please use global `run.go`.")
428-
}
429-
430-
// Deprecated since v1.47.0
431-
if l.cfg.LintersSettings.Gosimple.GoVersion != "" {
432-
l.log.Warnf("The configuration option `linters.gosimple.go` is deprecated, please use global `run.go`.")
433-
}
434-
435-
// Deprecated since v1.47.0
436-
if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
437-
l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
438-
}
439-
440-
// Deprecated since v1.60.0
441-
if l.cfg.LintersSettings.Unused.ExportedIsUsed != nil {
442-
l.log.Warnf("The configuration option `linters.unused.exported-is-used` is deprecated.")
443-
}
444-
445-
// Deprecated since v1.58.0
446-
if l.cfg.LintersSettings.SlogLint.ContextOnly != nil {
447-
l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.")
448-
l.cfg.LintersSettings.SlogLint.Context = cmp.Or(l.cfg.LintersSettings.SlogLint.Context, "all")
449-
}
450-
451-
// Deprecated since v1.51.0
452-
if l.cfg.LintersSettings.UseStdlibVars.OSDevNull != nil {
453-
l.log.Warnf("The configuration option `linters.usestdlibvars.os-dev-null` is deprecated.")
454-
}
455-
456-
// Deprecated since v1.51.0
457-
if l.cfg.LintersSettings.UseStdlibVars.SyslogPriority != nil {
458-
l.log.Warnf("The configuration option `linters.usestdlibvars.syslog-priority` is deprecated.")
459-
}
346+
func (*Loader) handleLinterOptionDeprecations() {
347+
// The function is empty but deprecations will happen in the future.
460348
}
461349

462350
func (l *Loader) handleEnableOnlyOption() error {
@@ -519,18 +407,9 @@ func (l *Loader) handleFormatterExclusions() {
519407
})
520408
}
521409
}
522-
func (l *Loader) handleFormatterDeprecations() {
523-
// Deprecated since v1.44.0.
524-
if l.cfg.Formatters.Settings.Gci.LocalPrefixes != "" {
525-
l.log.Warnf("The configuration option `formatters.settings.gci.local-prefixes` is deprecated, " +
526-
"please use `prefix()` inside `formatters.settings.gci.sections`.")
527-
}
528410

529-
// Deprecated since v1.47.0
530-
if l.cfg.Formatters.Settings.GoFumpt.LangVersion != "" {
531-
l.log.Warnf("The configuration option `formatters.settings.gofumpt.lang-version` is deprecated, " +
532-
"please use global `run.go`.")
533-
}
411+
func (*Loader) handleFormatterDeprecations() {
412+
// The function is empty but deprecations will happen in the future.
534413
}
535414

536415
func customDecoderHook() viper.DecoderConfigOption {

pkg/config/output.go

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ type Output struct {
1313
SortOrder []string `mapstructure:"sort-order"`
1414
PathPrefix string `mapstructure:"path-prefix"`
1515
ShowStats bool `mapstructure:"show-stats"`
16-
17-
// Deprecated: use [Issues.UniqByLine] instead.
18-
UniqByLine *bool `mapstructure:"uniq-by-line"`
1916
}
2017

2118
func (o *Output) Validate() error {

pkg/config/run.go

-10
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ type Run struct {
2727

2828
AllowParallelRunners bool `mapstructure:"allow-parallel-runners"`
2929
AllowSerialRunners bool `mapstructure:"allow-serial-runners"`
30-
31-
// Deprecated: use Issues.ExcludeFiles instead.
32-
SkipFiles []string `mapstructure:"skip-files"`
33-
// Deprecated: use Issues.ExcludeDirs instead.
34-
SkipDirs []string `mapstructure:"skip-dirs"`
35-
// Deprecated: use Issues.UseDefaultExcludeDirs instead.
36-
UseDefaultSkipDirs *bool `mapstructure:"skip-dirs-use-default"`
37-
38-
// Deprecated: use Output.ShowStats instead.
39-
ShowStats *bool `mapstructure:"show-stats"`
4030
}
4131

4232
func (r *Run) Validate() error {

pkg/goformatters/gci/gci.go

-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gci
22

33
import (
44
"context"
5-
"fmt"
65

76
gcicfg "github.com/daixiang0/gci/pkg/config"
87
"github.com/daixiang0/gci/pkg/gci"
@@ -41,14 +40,6 @@ func New(settings *config.GciSettings) (*Formatter, error) {
4140
ModPath: modPath,
4241
}
4342

44-
if settings.LocalPrefixes != "" {
45-
cfg.SectionStrings = []string{
46-
"standard",
47-
"default",
48-
fmt.Sprintf("prefix(%s)", settings.LocalPrefixes),
49-
}
50-
}
51-
5243
parsedCfg, err := cfg.Parse()
5344
if err != nil {
5445
return nil, err

0 commit comments

Comments
 (0)