Skip to content

Commit ecea1ca

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

File tree

2 files changed

+109
-107
lines changed

2 files changed

+109
-107
lines changed

pkg/config/linters_settings.go

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

55
var defaultLintersSettings = LintersSettings{
6+
Dogsled: DogsledSettings{
7+
MaxBlankIdentifiers: 2,
8+
},
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,
38+
MaxDeclChars: 30,
39+
},
640
Lll: LllSettings{
741
LineLength: 120,
842
TabWidth: 1,
943
},
10-
Unparam: UnparamSettings{
11-
Algo: "cha",
12-
},
1344
Nakedret: NakedretSettings{
1445
MaxFuncLines: 30,
1546
},
47+
Nestif: NestifSettings{
48+
MinComplexity: 5,
49+
},
50+
NoLintLint: NoLintLintSettings{
51+
RequireExplanation: false,
52+
AllowLeadingSpace: true,
53+
RequireSpecific: false,
54+
AllowUnused: false,
55+
},
1656
Prealloc: PreallocSettings{
1757
Simple: true,
1858
RangeLoops: true,
1959
ForLoops: false,
2060
},
21-
Gocritic: GocriticSettings{
22-
SettingsPerCheck: map[string]GocriticCheckSettings{},
23-
},
24-
Godox: GodoxSettings{
25-
Keywords: []string{},
61+
Predeclared: PredeclaredSettings{
62+
Ignore: "",
63+
Qualified: false,
2664
},
27-
Dogsled: DogsledSettings{
28-
MaxBlankIdentifiers: 2,
65+
Testpackage: TestpackageSettings{
66+
SkipRegexp: `(export|internal)_test\.go`,
2967
},
30-
Gocognit: GocognitSettings{
31-
MinComplexity: 30,
68+
Unparam: UnparamSettings{
69+
Algo: "cha",
3270
},
3371
WSL: WSLSettings{
3472
StrictAppend: true,
@@ -42,44 +80,6 @@ var defaultLintersSettings = LintersSettings{
4280
ForceExclusiveShortDeclarations: false,
4381
ForceCaseTrailingWhitespaceLimit: 0,
4482
},
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-
},
8383
}
8484

8585
type LintersSettings struct {
@@ -114,8 +114,8 @@ type LintersSettings struct {
114114
Gosimple StaticCheckSettings
115115
Govet GovetSettings
116116
Ifshort IfshortSettings
117-
Ireturn IreturnSettings
118117
ImportAs ImportAsSettings
118+
Ireturn IreturnSettings
119119
Lll LllSettings
120120
Makezero MakezeroSettings
121121
Maligned MalignedSettings
@@ -134,9 +134,9 @@ type LintersSettings struct {
134134
Structcheck StructCheckSettings
135135
Stylecheck StaticCheckSettings
136136
Tagliatelle TagliatelleSettings
137+
Tenv TenvSettings
137138
Testpackage TestpackageSettings
138139
Thelper ThelperSettings
139-
Tenv TenvSettings
140140
Unparam UnparamSettings
141141
Unused StaticCheckSettings
142142
Varcheck VarCheckSettings
@@ -166,11 +166,6 @@ type Cyclop struct {
166166
SkipTests bool `mapstructure:"skip-tests"`
167167
}
168168

169-
type ErrChkJSONSettings struct {
170-
CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
171-
ReportNoExported bool `mapstructure:"report-no-exported"`
172-
}
173-
174169
type DepGuardSettings struct {
175170
ListType string `mapstructure:"list-type"`
176171
Packages []string
@@ -196,6 +191,11 @@ type ErrcheckSettings struct {
196191
Exclude string `mapstructure:"exclude"`
197192
}
198193

194+
type ErrChkJSONSettings struct {
195+
CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
196+
ReportNoExported bool `mapstructure:"report-no-exported"`
197+
}
198+
199199
type ErrorLintSettings struct {
200200
Errorf bool `mapstructure:"errorf"`
201201
Asserts bool `mapstructure:"asserts"`
@@ -216,11 +216,6 @@ type ExhaustiveStructSettings struct {
216216
StructPatterns []string `mapstructure:"struct-patterns"`
217217
}
218218

219-
type IreturnSettings struct {
220-
Allow []string `mapstructure:"allow"`
221-
Reject []string `mapstructure:"reject"`
222-
}
223-
224219
type ForbidigoSettings struct {
225220
Forbid []string `mapstructure:"forbid"`
226221
ExcludeGodocExamples bool `mapstructure:"exclude-godoc-examples"`
@@ -366,6 +361,11 @@ type ImportAsAlias struct {
366361
Alias string
367362
}
368363

364+
type IreturnSettings struct {
365+
Allow []string `mapstructure:"allow"`
366+
Reject []string `mapstructure:"reject"`
367+
}
368+
369369
type LllSettings struct {
370370
LineLength int `mapstructure:"line-length"`
371371
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)