Skip to content

Commit b6a6faa

Browse files
authored
Add new presets (#1847)
1 parent cd6644d commit b6a6faa

File tree

2 files changed

+50
-32
lines changed

2 files changed

+50
-32
lines changed

pkg/lint/linter/config.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import (
55
)
66

77
const (
8-
PresetFormatting = "format"
9-
PresetComplexity = "complexity"
10-
PresetStyle = "style"
11-
PresetBugs = "bugs"
12-
PresetUnused = "unused"
13-
PresetPerformance = "performance"
8+
PresetBugs = "bugs" // Related to bugs detection.
9+
PresetComment = "comment" // Related to comments analysis.
10+
PresetComplexity = "complexity" // Related to code complexity analysis.
11+
PresetError = "error" // Related to error handling analysis.
12+
PresetFormatting = "format" // Related to code formatting.
13+
PresetImport = "import" // Related to imports analysis.
14+
PresetMetaLinter = "metalinter" // Related to linter that contains multiple rules or multiple linters.
15+
PresetModule = "module" // Related to Go modules analysis.
16+
PresetPerformance = "performance" // Related to performance.
17+
PresetSQL = "sql" // Related to SQL.
18+
PresetStyle = "style" // Related to coding style.
19+
PresetTest = "test" // Related to the analysis of the code of the tests.
20+
PresetUnused = "unused" // Related to the detection of unused code.
1421
)
1522

1623
type Config struct {

pkg/lint/lintersdb/manager.go

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,19 @@ func (m *Manager) WithCustomLinters() *Manager {
5959

6060
func (Manager) AllPresets() []string {
6161
return []string{
62-
linter.PresetBugs, linter.PresetComplexity, linter.PresetFormatting,
63-
linter.PresetPerformance, linter.PresetStyle, linter.PresetUnused,
62+
linter.PresetBugs,
63+
linter.PresetComment,
64+
linter.PresetComplexity,
65+
linter.PresetError,
66+
linter.PresetFormatting,
67+
linter.PresetImport,
68+
linter.PresetMetaLinter,
69+
linter.PresetModule,
70+
linter.PresetPerformance,
71+
linter.PresetSQL,
72+
linter.PresetStyle,
73+
linter.PresetTest,
74+
linter.PresetUnused,
6475
}
6576
}
6677

@@ -119,7 +130,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
119130
lcs := []*linter.Config{
120131
linter.NewConfig(golinters.NewGovet(govetCfg)).
121132
WithLoadForGoAnalysis().
122-
WithPresets(linter.PresetBugs).
133+
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
123134
WithAlternativeNames("vet", "vetshadow").
124135
WithURL("https://golang.org/cmd/vet/"),
125136
linter.NewConfig(golinters.NewBodyclose()).
@@ -132,20 +143,20 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
132143
WithURL("https://github.com/sonatard/noctx"),
133144
linter.NewConfig(golinters.NewErrcheck()).
134145
WithLoadForGoAnalysis().
135-
WithPresets(linter.PresetBugs).
146+
WithPresets(linter.PresetBugs, linter.PresetError).
136147
WithURL("https://github.com/kisielk/errcheck"),
137148
linter.NewConfig(golinters.NewGolint()).
138149
WithLoadForGoAnalysis().
139150
WithPresets(linter.PresetStyle).
140151
WithURL("https://github.com/golang/lint"),
141152
linter.NewConfig(golinters.NewRowsErrCheck()).
142153
WithLoadForGoAnalysis().
143-
WithPresets(linter.PresetPerformance, linter.PresetBugs).
154+
WithPresets(linter.PresetBugs, linter.PresetSQL).
144155
WithURL("https://github.com/jingyugao/rowserrcheck"),
145156

146157
linter.NewConfig(golinters.NewStaticcheck()).
147158
WithLoadForGoAnalysis().
148-
WithPresets(linter.PresetBugs).
159+
WithPresets(linter.PresetBugs, linter.PresetMetaLinter).
149160
WithAlternativeNames(megacheckName).
150161
WithURL("https://staticcheck.io/"),
151162
linter.NewConfig(golinters.NewUnused()).
@@ -229,15 +240,15 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
229240
WithAutoFix().
230241
WithURL("https://github.com/mvdan/gofumpt"),
231242
linter.NewConfig(golinters.NewGoimports()).
232-
WithPresets(linter.PresetFormatting).
243+
WithPresets(linter.PresetFormatting, linter.PresetImport).
233244
WithAutoFix().
234245
WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"),
235246
linter.NewConfig(golinters.NewGoHeader()).
236247
WithPresets(linter.PresetStyle).
237248
WithLoadForGoAnalysis().
238249
WithURL("https://github.com/denis-tingajkin/go-header"),
239250
linter.NewConfig(golinters.NewGci()).
240-
WithPresets(linter.PresetFormatting).
251+
WithPresets(linter.PresetFormatting, linter.PresetImport).
241252
WithLoadForGoAnalysis().
242253
WithAutoFix().
243254
WithURL("https://github.com/daixiang0/gci"),
@@ -248,10 +259,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
248259
Deprecated("The repository of the linter has been archived by the owner. Use govet 'fieldalignment' instead."),
249260
linter.NewConfig(golinters.NewDepguard()).
250261
WithLoadForGoAnalysis().
251-
WithPresets(linter.PresetStyle).
262+
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
252263
WithURL("https://github.com/OpenPeeDeeP/depguard"),
253264
linter.NewConfig(golinters.NewMisspell()).
254-
WithPresets(linter.PresetStyle).
265+
WithPresets(linter.PresetStyle, linter.PresetComment).
255266
WithAutoFix().
256267
WithURL("https://github.com/client9/misspell"),
257268
linter.NewConfig(golinters.NewLLL()).
@@ -264,7 +275,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
264275
WithPresets(linter.PresetStyle).
265276
WithURL("https://github.com/alexkohler/dogsled"),
266277
linter.NewConfig(golinters.NewNakedret()).
267-
WithPresets(linter.PresetComplexity).
278+
WithPresets(linter.PresetStyle).
268279
WithURL("https://github.com/alexkohler/nakedret"),
269280
linter.NewConfig(golinters.NewPrealloc()).
270281
WithPresets(linter.PresetPerformance).
@@ -274,7 +285,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
274285
WithURL("https://github.com/kyoh86/scopelint").
275286
Deprecated("The repository of the linter has been deprecated by the owner. Use 'exportloopref' instead."),
276287
linter.NewConfig(golinters.NewGocritic()).
277-
WithPresets(linter.PresetStyle).
288+
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
278289
WithLoadForGoAnalysis().
279290
WithURL("https://github.com/go-critic/go-critic"),
280291
linter.NewConfig(golinters.NewGochecknoinits()).
@@ -284,10 +295,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
284295
WithPresets(linter.PresetStyle).
285296
WithURL("https://github.com/leighmcculloch/gochecknoglobals"),
286297
linter.NewConfig(golinters.NewGodox()).
287-
WithPresets(linter.PresetStyle).
298+
WithPresets(linter.PresetStyle, linter.PresetComment).
288299
WithURL("https://github.com/matoous/godox"),
289300
linter.NewConfig(golinters.NewFunlen()).
290-
WithPresets(linter.PresetStyle).
301+
WithPresets(linter.PresetComplexity).
291302
WithURL("https://github.com/ultraware/funlen"),
292303
linter.NewConfig(golinters.NewWhitespace()).
293304
WithPresets(linter.PresetStyle).
@@ -303,19 +314,19 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
303314
WithPresets(linter.PresetStyle).
304315
WithURL("https://github.com/tommy-muehle/go-mnd"),
305316
linter.NewConfig(golinters.NewGoerr113()).
306-
WithPresets(linter.PresetStyle).
317+
WithPresets(linter.PresetStyle, linter.PresetError).
307318
WithLoadForGoAnalysis().
308319
WithURL("https://github.com/Djarvur/go-err113"),
309320
linter.NewConfig(golinters.NewGomodguard()).
310-
WithPresets(linter.PresetStyle).
321+
WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule).
311322
WithLoadForGoAnalysis().
312323
WithURL("https://github.com/ryancurrah/gomodguard"),
313324
linter.NewConfig(golinters.NewGodot()).
314-
WithPresets(linter.PresetStyle).
325+
WithPresets(linter.PresetStyle, linter.PresetComment).
315326
WithAutoFix().
316327
WithURL("https://github.com/tetafro/godot"),
317328
linter.NewConfig(golinters.NewTestpackage(testpackageCfg)).
318-
WithPresets(linter.PresetStyle).
329+
WithPresets(linter.PresetStyle, linter.PresetTest).
319330
WithLoadForGoAnalysis().
320331
WithURL("https://github.com/maratori/testpackage"),
321332
linter.NewConfig(golinters.NewNestif()).
@@ -330,35 +341,35 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
330341
WithLoadForGoAnalysis().
331342
WithURL("https://github.com/nishanths/exhaustive"),
332343
linter.NewConfig(golinters.NewSQLCloseCheck()).
333-
WithPresets(linter.PresetBugs).
344+
WithPresets(linter.PresetBugs, linter.PresetSQL).
334345
WithLoadForGoAnalysis().
335346
WithURL("https://github.com/ryanrolds/sqlclosecheck"),
336347
linter.NewConfig(golinters.NewNLReturn()).
337348
WithPresets(linter.PresetStyle).
338349
WithLoadForGoAnalysis().
339350
WithURL("https://github.com/ssgreg/nlreturn"),
340351
linter.NewConfig(golinters.NewWrapcheck()).
341-
WithPresets(linter.PresetStyle).
352+
WithPresets(linter.PresetStyle, linter.PresetError).
342353
WithLoadForGoAnalysis().
343354
WithURL("https://github.com/tomarrell/wrapcheck"),
344355
linter.NewConfig(golinters.NewThelper(thelperCfg)).
345356
WithPresets(linter.PresetStyle).
346357
WithLoadForGoAnalysis().
347358
WithURL("https://github.com/kulti/thelper"),
348359
linter.NewConfig(golinters.NewTparallel()).
349-
WithPresets(linter.PresetStyle).
360+
WithPresets(linter.PresetStyle, linter.PresetTest).
350361
WithLoadForGoAnalysis().
351362
WithURL("https://github.com/moricho/tparallel"),
352363
linter.NewConfig(golinters.NewExhaustiveStruct(exhaustiveStructCfg)).
353-
WithPresets(linter.PresetStyle).
364+
WithPresets(linter.PresetStyle, linter.PresetTest).
354365
WithLoadForGoAnalysis().
355366
WithURL("https://github.com/mbilski/exhaustivestruct"),
356367
linter.NewConfig(golinters.NewErrorLint(errorlintCfg)).
357-
WithPresets(linter.PresetBugs).
368+
WithPresets(linter.PresetBugs, linter.PresetError).
358369
WithLoadForGoAnalysis().
359370
WithURL("https://github.com/polyfloyd/go-errorlint"),
360371
linter.NewConfig(golinters.NewParallelTest()).
361-
WithPresets(linter.PresetStyle).
372+
WithPresets(linter.PresetStyle, linter.PresetTest).
362373
WithLoadForGoAnalysis().
363374
WithURL("https://github.com/kunwardeep/paralleltest"),
364375
linter.NewConfig(golinters.NewMakezero()).
@@ -375,7 +386,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
375386
WithPresets(linter.PresetStyle).
376387
WithURL("https://github.com/nishanths/predeclared"),
377388
linter.NewConfig(golinters.NewRevive(reviveCfg)).
378-
WithPresets(linter.PresetStyle).
389+
WithPresets(linter.PresetStyle, linter.PresetMetaLinter).
379390
ConsiderSlow().
380391
WithURL("https://github.com/mgechev/revive"),
381392
linter.NewConfig(golinters.NewDurationCheck()).
@@ -399,7 +410,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
399410
WithLoadForGoAnalysis().
400411
WithURL("https://github.com/gostaticanalysis/forcetypeassert"),
401412
linter.NewConfig(golinters.NewGoModDirectives(goModDirectivesCfg)).
402-
WithPresets(linter.PresetStyle).
413+
WithPresets(linter.PresetStyle, linter.PresetModule).
403414
WithLoadForGoAnalysis().
404415
WithURL("https://github.com/ldez/gomoddirectives"),
405416

0 commit comments

Comments
 (0)