Skip to content

Commit 4b1efea

Browse files
committed
review: enforce alphabetical order
1 parent 7fb261c commit 4b1efea

File tree

2 files changed

+111
-112
lines changed

2 files changed

+111
-112
lines changed

pkg/config/linters_settings.go

+64-67
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,67 @@ package config
33
import "github.com/pkg/errors"
44

55
var defaultLintersSettings = LintersSettings{
6-
Lll: LllSettings{
7-
LineLength: 120,
8-
TabWidth: 1,
6+
Dogsled: DogsledSettings{
7+
MaxBlankIdentifiers: 2,
98
},
10-
Unparam: UnparamSettings{
11-
Algo: "cha",
9+
ErrorLint: ErrorLintSettings{
10+
Errorf: true,
11+
Asserts: true,
12+
Comparison: true,
13+
},
14+
Exhaustive: ExhaustiveSettings{
15+
CheckGenerated: false,
16+
DefaultSignifiesExhaustive: false,
17+
IgnoreEnumMembers: "",
18+
CheckingStrategy: "value",
19+
},
20+
Forbidigo: ForbidigoSettings{
21+
ExcludeGodocExamples: true,
22+
},
23+
Gocognit: GocognitSettings{
24+
MinComplexity: 30,
25+
},
26+
Gocritic: GocriticSettings{
27+
SettingsPerCheck: map[string]GocriticCheckSettings{},
28+
},
29+
Godox: GodoxSettings{
30+
Keywords: []string{},
31+
},
32+
Gofumpt: GofumptSettings{
33+
LangVersion: "",
34+
ExtraRules: false,
35+
},
36+
Ifshort: IfshortSettings{
37+
MaxDeclLines: 1, MaxDeclChars: 30,
38+
},
39+
Lll: LllSettings{
40+
LineLength: 120, TabWidth: 1,
1241
},
1342
Nakedret: NakedretSettings{
1443
MaxFuncLines: 30,
1544
},
45+
Nestif: NestifSettings{
46+
MinComplexity: 5,
47+
},
48+
NoLintLint: NoLintLintSettings{
49+
RequireExplanation: false,
50+
AllowLeadingSpace: true,
51+
RequireSpecific: false,
52+
AllowUnused: false,
53+
},
1654
Prealloc: PreallocSettings{
1755
Simple: true,
1856
RangeLoops: true,
1957
ForLoops: false,
2058
},
21-
Gocritic: GocriticSettings{
22-
SettingsPerCheck: map[string]GocriticCheckSettings{},
23-
},
24-
Godox: GodoxSettings{
25-
Keywords: []string{},
59+
Predeclared: PredeclaredSettings{
60+
Ignore: "", Qualified: false,
2661
},
27-
Dogsled: DogsledSettings{
28-
MaxBlankIdentifiers: 2,
62+
Testpackage: TestpackageSettings{
63+
SkipRegexp: `(export|internal)_test\.go`,
2964
},
30-
Gocognit: GocognitSettings{
31-
MinComplexity: 30,
65+
Unparam: UnparamSettings{
66+
Algo: "cha",
3267
},
3368
WSL: WSLSettings{
3469
StrictAppend: true,
@@ -42,44 +77,6 @@ var defaultLintersSettings = LintersSettings{
4277
ForceExclusiveShortDeclarations: false,
4378
ForceCaseTrailingWhitespaceLimit: 0,
4479
},
45-
NoLintLint: NoLintLintSettings{
46-
RequireExplanation: false,
47-
AllowLeadingSpace: true,
48-
RequireSpecific: false,
49-
AllowUnused: false,
50-
},
51-
Testpackage: TestpackageSettings{
52-
SkipRegexp: `(export|internal)_test\.go`,
53-
},
54-
Nestif: NestifSettings{
55-
MinComplexity: 5,
56-
},
57-
Exhaustive: ExhaustiveSettings{
58-
CheckGenerated: false,
59-
DefaultSignifiesExhaustive: false,
60-
IgnoreEnumMembers: "",
61-
CheckingStrategy: "value",
62-
},
63-
Gofumpt: GofumptSettings{
64-
LangVersion: "",
65-
ExtraRules: false,
66-
},
67-
ErrorLint: ErrorLintSettings{
68-
Errorf: true,
69-
Asserts: true,
70-
Comparison: true,
71-
},
72-
Ifshort: IfshortSettings{
73-
MaxDeclLines: 1,
74-
MaxDeclChars: 30,
75-
},
76-
Predeclared: PredeclaredSettings{
77-
Ignore: "",
78-
Qualified: false,
79-
},
80-
Forbidigo: ForbidigoSettings{
81-
ExcludeGodocExamples: true,
82-
},
8380
}
8481

8582
type LintersSettings struct {
@@ -88,14 +85,15 @@ type LintersSettings struct {
8885
Depguard DepGuardSettings
8986
Dogsled DogsledSettings
9087
Dupl DuplSettings
91-
Errcheck ErrcheckSettings
9288
ErrChkJSON ErrChkJSONSettings
89+
Errcheck ErrcheckSettings
9390
ErrorLint ErrorLintSettings
9491
Exhaustive ExhaustiveSettings
9592
ExhaustiveStruct ExhaustiveStructSettings
9693
Forbidigo ForbidigoSettings
9794
Funlen FunlenSettings
9895
Gci GciSettings
96+
GoModDirectives GoModDirectivesSettings
9997
Gocognit GocognitSettings
10098
Goconst GoConstSettings
10199
Gocritic GocriticSettings
@@ -108,14 +106,13 @@ type LintersSettings struct {
108106
Goimports GoImportsSettings
109107
Golint GoLintSettings
110108
Gomnd GoMndSettings
111-
GoModDirectives GoModDirectivesSettings
112109
Gomodguard GoModGuardSettings
113110
Gosec GoSecSettings
114111
Gosimple StaticCheckSettings
115112
Govet GovetSettings
116113
Ifshort IfshortSettings
117-
Ireturn IreturnSettings
118114
ImportAs ImportAsSettings
115+
Ireturn IreturnSettings
119116
Lll LllSettings
120117
Makezero MakezeroSettings
121118
Maligned MalignedSettings
@@ -134,16 +131,16 @@ type LintersSettings struct {
134131
Structcheck StructCheckSettings
135132
Stylecheck StaticCheckSettings
136133
Tagliatelle TagliatelleSettings
134+
Tenv TenvSettings
137135
Testpackage TestpackageSettings
138136
Thelper ThelperSettings
139-
Tenv TenvSettings
140137
Unparam UnparamSettings
141138
Unused StaticCheckSettings
142139
Varcheck VarCheckSettings
143140
Varnamelen VarnamelenSettings
141+
WSL WSLSettings
144142
Whitespace WhitespaceSettings
145143
Wrapcheck WrapcheckSettings
146-
WSL WSLSettings
147144

148145
Custom map[string]CustomLinterSettings
149146
}
@@ -166,11 +163,6 @@ type Cyclop struct {
166163
SkipTests bool `mapstructure:"skip-tests"`
167164
}
168165

169-
type ErrChkJSONSettings struct {
170-
CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
171-
ReportNoExported bool `mapstructure:"report-no-exported"`
172-
}
173-
174166
type DepGuardSettings struct {
175167
ListType string `mapstructure:"list-type"`
176168
Packages []string
@@ -196,6 +188,11 @@ type ErrcheckSettings struct {
196188
Exclude string `mapstructure:"exclude"`
197189
}
198190

191+
type ErrChkJSONSettings struct {
192+
CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
193+
ReportNoExported bool `mapstructure:"report-no-exported"`
194+
}
195+
199196
type ErrorLintSettings struct {
200197
Errorf bool `mapstructure:"errorf"`
201198
Asserts bool `mapstructure:"asserts"`
@@ -216,11 +213,6 @@ type ExhaustiveStructSettings struct {
216213
StructPatterns []string `mapstructure:"struct-patterns"`
217214
}
218215

219-
type IreturnSettings struct {
220-
Allow []string `mapstructure:"allow"`
221-
Reject []string `mapstructure:"reject"`
222-
}
223-
224216
type ForbidigoSettings struct {
225217
Forbid []string `mapstructure:"forbid"`
226218
ExcludeGodocExamples bool `mapstructure:"exclude-godoc-examples"`
@@ -366,6 +358,11 @@ type ImportAsAlias struct {
366358
Alias string
367359
}
368360

361+
type IreturnSettings struct {
362+
Allow []string `mapstructure:"allow"`
363+
Reject []string `mapstructure:"reject"`
364+
}
365+
369366
type LllSettings struct {
370367
LineLength int `mapstructure:"line-length"`
371368
TabWidth int `mapstructure:"tab-width"`

pkg/lint/lintersdb/manager.go

+47-45
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
158158

159159
const megacheckName = "megacheck"
160160

161+
// The linters are in the alphabetical order (case-insensitive).
162+
// When a new linter is added the version in `WithSince(...)` must be the next version of golangci-lint.
161163
lcs := []*linter.Config{
162164
linter.NewConfig(golinters.NewAsciicheck()).
163165
WithSince("v1.26.0").
@@ -233,6 +235,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
233235
WithLoadForGoAnalysis().
234236
WithURL("https://github.com/Antonboom/errname"),
235237

238+
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
239+
WithSince("v1.32.0").
240+
WithPresets(linter.PresetBugs, linter.PresetError).
241+
WithLoadForGoAnalysis().
242+
WithURL("https://github.com/polyfloyd/go-errorlint"),
243+
236244
linter.NewConfig(golinters.NewExhaustive(exhaustiveCfg)).
237245
WithSince(" v1.28.0").
238246
WithPresets(linter.PresetBugs).
@@ -272,39 +280,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
272280
WithAutoFix().
273281
WithURL("https://github.com/daixiang0/gci"),
274282

275-
linter.NewConfig(golinters.NewGocritic()).
276-
WithSince("v1.12.0").
277-
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
278-
WithLoadForGoAnalysis().
279-
WithURL("https://github.com/go-critic/go-critic"),
280-
281-
linter.NewConfig(golinters.NewGoerr113()).
282-
WithSince("v1.26.0").
283-
WithPresets(linter.PresetStyle, linter.PresetError).
284-
WithLoadForGoAnalysis().
285-
WithURL("https://github.com/Djarvur/go-err113"),
286-
287-
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
288-
WithSince("v1.32.0").
289-
WithPresets(linter.PresetBugs, linter.PresetError).
290-
WithLoadForGoAnalysis().
291-
WithURL("https://github.com/polyfloyd/go-errorlint"),
292-
293-
linter.NewConfig(golinters.NewGoHeader()).
294-
WithSince("v1.28.0").
295-
WithPresets(linter.PresetStyle).
296-
WithURL("https://github.com/denis-tingajkin/go-header"),
297-
298-
linter.NewConfig(golinters.NewGoMND(m.cfg)).
299-
WithSince("v1.22.0").
300-
WithPresets(linter.PresetStyle).
301-
WithURL("https://github.com/tommy-muehle/go-mnd"),
302-
303-
linter.NewConfig(golinters.NewGoPrintfFuncName()).
304-
WithSince("v1.23.0").
305-
WithPresets(linter.PresetStyle).
306-
WithURL("https://github.com/jirfag/go-printf-func-name"),
307-
308283
linter.NewConfig(golinters.NewGochecknoglobals()).
309284
WithSince("v1.12.0").
310285
WithPresets(linter.PresetStyle).
@@ -325,6 +300,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
325300
WithPresets(linter.PresetStyle).
326301
WithURL("https://github.com/jgautheron/goconst"),
327302

303+
linter.NewConfig(golinters.NewGocritic()).
304+
WithSince("v1.12.0").
305+
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
306+
WithLoadForGoAnalysis().
307+
WithURL("https://github.com/go-critic/go-critic"),
308+
328309
linter.NewConfig(golinters.NewGocyclo()).
329310
WithSince("v1.0.0").
330311
WithPresets(linter.PresetComplexity).
@@ -341,6 +322,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
341322
WithPresets(linter.PresetStyle, linter.PresetComment).
342323
WithURL("https://github.com/matoous/godox"),
343324

325+
linter.NewConfig(golinters.NewGoerr113()).
326+
WithSince("v1.26.0").
327+
WithPresets(linter.PresetStyle, linter.PresetError).
328+
WithLoadForGoAnalysis().
329+
WithURL("https://github.com/Djarvur/go-err113"),
330+
344331
linter.NewConfig(golinters.NewGofmt()).
345332
WithSince("v1.0.0").
346333
WithPresets(linter.PresetFormatting).
@@ -353,12 +340,29 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
353340
WithAutoFix().
354341
WithURL("https://github.com/mvdan/gofumpt"),
355342

343+
linter.NewConfig(golinters.NewGoHeader()).
344+
WithSince("v1.28.0").
345+
WithPresets(linter.PresetStyle).
346+
WithURL("https://github.com/denis-tingajkin/go-header"),
347+
356348
linter.NewConfig(golinters.NewGoimports()).
357349
WithSince("v1.20.0").
358350
WithPresets(linter.PresetFormatting, linter.PresetImport).
359351
WithAutoFix().
360352
WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"),
361353

354+
linter.NewConfig(golinters.NewGolint()).
355+
WithSince("v1.0.0").
356+
WithLoadForGoAnalysis().
357+
WithPresets(linter.PresetStyle).
358+
WithURL("https://github.com/golang/lint").
359+
Deprecated("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"),
360+
361+
linter.NewConfig(golinters.NewGoMND(m.cfg)).
362+
WithSince("v1.22.0").
363+
WithPresets(linter.PresetStyle).
364+
WithURL("https://github.com/tommy-muehle/go-mnd"),
365+
362366
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
363367
WithSince("v1.39.0").
364368
WithPresets(linter.PresetStyle, linter.PresetModule).
@@ -369,6 +373,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
369373
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
370374
WithURL("https://github.com/ryancurrah/gomodguard"),
371375

376+
linter.NewConfig(golinters.NewGoPrintfFuncName()).
377+
WithSince("v1.23.0").
378+
WithPresets(linter.PresetStyle).
379+
WithURL("https://github.com/jirfag/go-printf-func-name"),
380+
372381
linter.NewConfig(golinters.NewGosec(gosecCfg)).
373382
WithSince("v1.0.0").
374383
WithLoadForGoAnalysis().
@@ -419,13 +428,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
419428
WithLoadForGoAnalysis().
420429
WithURL("https://github.com/butuzov/ireturn"),
421430

422-
linter.NewConfig(golinters.NewGolint()).
423-
WithSince("v1.0.0").
424-
WithLoadForGoAnalysis().
425-
WithPresets(linter.PresetStyle).
426-
WithURL("https://github.com/golang/lint").
427-
Deprecated("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"),
428-
429431
linter.NewConfig(golinters.NewLLL()).
430432
WithSince("v1.8.0").
431433
WithPresets(linter.PresetStyle),
@@ -624,17 +626,17 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
624626
WithAutoFix().
625627
WithURL("https://github.com/ultraware/whitespace"),
626628

627-
linter.NewConfig(golinters.NewWSL()).
628-
WithSince("v1.20.0").
629-
WithPresets(linter.PresetStyle).
630-
WithURL("https://github.com/bombsimon/wsl"),
631-
632629
linter.NewConfig(golinters.NewWrapcheck(wrapcheckCfg)).
633630
WithSince("v1.32.0").
634631
WithPresets(linter.PresetStyle, linter.PresetError).
635632
WithLoadForGoAnalysis().
636633
WithURL("https://github.com/tomarrell/wrapcheck"),
637634

635+
linter.NewConfig(golinters.NewWSL()).
636+
WithSince("v1.20.0").
637+
WithPresets(linter.PresetStyle).
638+
WithURL("https://github.com/bombsimon/wsl"),
639+
638640
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
639641
linter.NewConfig(golinters.NewNoLintLint()).
640642
WithSince("v1.26.0").

0 commit comments

Comments
 (0)