-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathlinters_settings.go
962 lines (849 loc) · 30.7 KB
/
linters_settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
package config
import (
"encoding"
"errors"
"runtime"
"gopkg.in/yaml.v3"
)
var defaultLintersSettings = LintersSettings{
Asasalint: AsasalintSettings{
UseBuiltinExclusions: true,
},
Decorder: DecorderSettings{
DecOrder: []string{"type", "const", "var", "func"},
DisableDecNumCheck: true,
DisableDecOrderCheck: true,
DisableInitFuncFirstCheck: true,
},
Dogsled: DogsledSettings{
MaxBlankIdentifiers: 2,
},
ErrorLint: ErrorLintSettings{
Errorf: true,
ErrorfMulti: true,
Asserts: true,
Comparison: true,
},
Exhaustive: ExhaustiveSettings{
Check: []string{"switch"},
CheckGenerated: false,
DefaultSignifiesExhaustive: false,
IgnoreEnumMembers: "",
PackageScopeOnly: false,
ExplicitExhaustiveMap: false,
ExplicitExhaustiveSwitch: false,
},
Forbidigo: ForbidigoSettings{
ExcludeGodocExamples: true,
},
Gci: GciSettings{
Sections: []string{"standard", "default"},
SkipGenerated: true,
},
Gocognit: GocognitSettings{
MinComplexity: 30,
},
Gocritic: GoCriticSettings{
SettingsPerCheck: map[string]GoCriticCheckSettings{},
},
Godox: GodoxSettings{
Keywords: []string{},
},
Godot: GodotSettings{
Scope: "declarations",
Period: true,
},
Gofumpt: GofumptSettings{
LangVersion: "",
ModulePath: "",
ExtraRules: false,
},
Gosec: GoSecSettings{
Concurrency: runtime.NumCPU(),
},
Gosmopolitan: GosmopolitanSettings{
AllowTimeLocal: false,
EscapeHatches: []string{},
IgnoreTests: true,
WatchForScripts: []string{"Han"},
},
Ifshort: IfshortSettings{
MaxDeclLines: 1,
MaxDeclChars: 30,
},
Inamedparam: INamedParamSettings{
SkipSingleParam: false,
},
InterfaceBloat: InterfaceBloatSettings{
Max: 10,
},
Lll: LllSettings{
LineLength: 120,
TabWidth: 1,
},
LoggerCheck: LoggerCheckSettings{
Kitlog: true,
Klog: true,
Logr: true,
Zap: true,
RequireStringKey: false,
NoPrintfLike: false,
Rules: nil,
},
MaintIdx: MaintIdxSettings{
Under: 20,
},
Nakedret: NakedretSettings{
MaxFuncLines: 30,
},
Nestif: NestifSettings{
MinComplexity: 5,
},
NoLintLint: NoLintLintSettings{
RequireExplanation: false,
RequireSpecific: false,
AllowUnused: false,
},
PerfSprint: PerfSprintSettings{
IntConversion: true,
ErrError: false,
ErrorF: true,
SprintF1: true,
},
Prealloc: PreallocSettings{
Simple: true,
RangeLoops: true,
ForLoops: false,
},
Predeclared: PredeclaredSettings{
Ignore: "",
Qualified: false,
},
SlogLint: SlogLintSettings{
NoMixedArgs: true,
KVOnly: false,
AttrOnly: false,
ContextOnly: false,
StaticMsg: false,
NoRawKeys: false,
KeyNamingCase: "",
ArgsOnSepLines: false,
},
TagAlign: TagAlignSettings{
Align: true,
Sort: true,
Order: nil,
Strict: false,
},
Testpackage: TestpackageSettings{
SkipRegexp: `(export|internal)_test\.go`,
AllowPackages: []string{"main"},
},
Unparam: UnparamSettings{
Algo: "cha",
},
Unused: UnusedSettings{
FieldWritesAreUses: true,
PostStatementsAreReads: false,
ExportedIsUsed: true,
ExportedFieldsAreUsed: true,
ParametersAreUsed: true,
LocalVariablesAreUsed: true,
GeneratedIsUsed: true,
},
UseStdlibVars: UseStdlibVarsSettings{
HTTPMethod: true,
HTTPStatusCode: true,
},
Varnamelen: VarnamelenSettings{
MaxDistance: 5,
MinNameLength: 3,
},
WSL: WSLSettings{
StrictAppend: true,
AllowAssignAndCallCuddle: true,
AllowAssignAndAnythingCuddle: false,
AllowMultiLineAssignCuddle: true,
ForceCaseTrailingWhitespaceLimit: 0,
AllowTrailingComment: false,
AllowSeparatedLeadingComment: false,
AllowCuddleDeclaration: false,
AllowCuddleWithCalls: []string{"Lock", "RLock"},
AllowCuddleWithRHS: []string{"Unlock", "RUnlock"},
ForceCuddleErrCheckAndAssign: false,
ErrorVariableNames: []string{"err"},
ForceExclusiveShortDeclarations: false,
},
}
type LintersSettings struct {
Asasalint AsasalintSettings
BiDiChk BiDiChkSettings
Cyclop Cyclop
Decorder DecorderSettings
Depguard DepGuardSettings
Dogsled DogsledSettings
Dupl DuplSettings
DupWord DupWordSettings
Errcheck ErrcheckSettings
ErrChkJSON ErrChkJSONSettings
ErrorLint ErrorLintSettings
Exhaustive ExhaustiveSettings
ExhaustiveStruct ExhaustiveStructSettings
Exhaustruct ExhaustructSettings
Forbidigo ForbidigoSettings
Funlen FunlenSettings
Gci GciSettings
GinkgoLinter GinkgoLinterSettings
Gocognit GocognitSettings
Goconst GoConstSettings
Gocritic GoCriticSettings
Gocyclo GoCycloSettings
Godot GodotSettings
Godox GodoxSettings
Gofmt GoFmtSettings
Gofumpt GofumptSettings
Goheader GoHeaderSettings
Goimports GoImportsSettings
Golint GoLintSettings
Gomnd GoMndSettings
GoModDirectives GoModDirectivesSettings
Gomodguard GoModGuardSettings
Gosec GoSecSettings
Gosimple CommonStaticCheckSettings
Gosmopolitan GosmopolitanSettings
Govet GovetSettings
Grouper GrouperSettings
Ifshort IfshortSettings
ImportAs ImportAsSettings
Inamedparam INamedParamSettings
InterfaceBloat InterfaceBloatSettings
Ireturn IreturnSettings
Lll LllSettings
LoggerCheck LoggerCheckSettings
MaintIdx MaintIdxSettings
Makezero MakezeroSettings
Maligned MalignedSettings
Misspell MisspellSettings
MustTag MustTagSettings
Nakedret NakedretSettings
Nestif NestifSettings
NilNil NilNilSettings
Nlreturn NlreturnSettings
NoLintLint NoLintLintSettings
NoNamedReturns NoNamedReturnsSettings
ParallelTest ParallelTestSettings
PerfSprint PerfSprintSettings
Prealloc PreallocSettings
Predeclared PredeclaredSettings
Promlinter PromlinterSettings
ProtoGetter ProtoGetterSettings
Reassign ReassignSettings
Revive ReviveSettings
RowsErrCheck RowsErrCheckSettings
SlogLint SlogLintSettings
Staticcheck CommonStaticCheckSettings
Structcheck StructCheckSettings
Stylecheck StaticCheckSettings
TagAlign TagAlignSettings
Tagliatelle TagliatelleSettings
Testifylint TestifylintSettings
Tenv TenvSettings
Testpackage TestpackageSettings
Thelper ThelperSettings
Unparam UnparamSettings
Unused UnusedSettings
UseStdlibVars UseStdlibVarsSettings
Varcheck VarCheckSettings
Varnamelen VarnamelenSettings
Whitespace WhitespaceSettings
Wrapcheck WrapcheckSettings
WSL WSLSettings
Custom map[string]CustomLinterSettings
}
type AsasalintSettings struct {
Exclude []string `mapstructure:"exclude"`
UseBuiltinExclusions bool `mapstructure:"use-builtin-exclusions"`
IgnoreTest bool `mapstructure:"ignore-test"`
}
type BiDiChkSettings struct {
LeftToRightEmbedding bool `mapstructure:"left-to-right-embedding"`
RightToLeftEmbedding bool `mapstructure:"right-to-left-embedding"`
PopDirectionalFormatting bool `mapstructure:"pop-directional-formatting"`
LeftToRightOverride bool `mapstructure:"left-to-right-override"`
RightToLeftOverride bool `mapstructure:"right-to-left-override"`
LeftToRightIsolate bool `mapstructure:"left-to-right-isolate"`
RightToLeftIsolate bool `mapstructure:"right-to-left-isolate"`
FirstStrongIsolate bool `mapstructure:"first-strong-isolate"`
PopDirectionalIsolate bool `mapstructure:"pop-directional-isolate"`
}
type Cyclop struct {
MaxComplexity int `mapstructure:"max-complexity"`
PackageAverage float64 `mapstructure:"package-average"`
SkipTests bool `mapstructure:"skip-tests"`
}
type DepGuardSettings struct {
Rules map[string]*DepGuardList `mapstructure:"rules"`
}
type DepGuardList struct {
ListMode string `mapstructure:"list-mode"`
Files []string `mapstructure:"files"`
Allow []string `mapstructure:"allow"`
Deny []DepGuardDeny `mapstructure:"deny"`
}
type DepGuardDeny struct {
Pkg string `mapstructure:"pkg"`
Desc string `mapstructure:"desc"`
}
type DecorderSettings struct {
DecOrder []string `mapstructure:"dec-order"`
IgnoreUnderscoreVars bool `mapstructure:"ignore-underscore-vars"`
DisableDecNumCheck bool `mapstructure:"disable-dec-num-check"`
DisableTypeDecNumCheck bool `mapstructure:"disable-type-dec-num-check"`
DisableConstDecNumCheck bool `mapstructure:"disable-const-dec-num-check"`
DisableVarDecNumCheck bool `mapstructure:"disable-var-dec-num-check"`
DisableDecOrderCheck bool `mapstructure:"disable-dec-order-check"`
DisableInitFuncFirstCheck bool `mapstructure:"disable-init-func-first-check"`
}
type DogsledSettings struct {
MaxBlankIdentifiers int `mapstructure:"max-blank-identifiers"`
}
type DuplSettings struct {
Threshold int
}
type DupWordSettings struct {
Keywords []string `mapstructure:"keywords"`
Ignore []string `mapstructure:"ignore"`
}
type ErrcheckSettings struct {
DisableDefaultExclusions bool `mapstructure:"disable-default-exclusions"`
CheckTypeAssertions bool `mapstructure:"check-type-assertions"`
CheckAssignToBlank bool `mapstructure:"check-blank"`
Ignore string `mapstructure:"ignore"`
ExcludeFunctions []string `mapstructure:"exclude-functions"`
// Deprecated: use ExcludeFunctions instead
Exclude string `mapstructure:"exclude"`
}
type ErrChkJSONSettings struct {
CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
ReportNoExported bool `mapstructure:"report-no-exported"`
}
type ErrorLintSettings struct {
Errorf bool `mapstructure:"errorf"`
ErrorfMulti bool `mapstructure:"errorf-multi"`
Asserts bool `mapstructure:"asserts"`
Comparison bool `mapstructure:"comparison"`
}
type ExhaustiveSettings struct {
Check []string `mapstructure:"check"`
CheckGenerated bool `mapstructure:"check-generated"`
DefaultSignifiesExhaustive bool `mapstructure:"default-signifies-exhaustive"`
IgnoreEnumMembers string `mapstructure:"ignore-enum-members"`
IgnoreEnumTypes string `mapstructure:"ignore-enum-types"`
PackageScopeOnly bool `mapstructure:"package-scope-only"`
ExplicitExhaustiveMap bool `mapstructure:"explicit-exhaustive-map"`
ExplicitExhaustiveSwitch bool `mapstructure:"explicit-exhaustive-switch"`
DefaultCaseRequired bool `mapstructure:"default-case-required"`
}
type ExhaustiveStructSettings struct {
StructPatterns []string `mapstructure:"struct-patterns"`
}
type ExhaustructSettings struct {
Include []string `mapstructure:"include"`
Exclude []string `mapstructure:"exclude"`
}
type ForbidigoSettings struct {
Forbid []ForbidigoPattern `mapstructure:"forbid"`
ExcludeGodocExamples bool `mapstructure:"exclude-godoc-examples"`
AnalyzeTypes bool `mapstructure:"analyze-types"`
}
var _ encoding.TextUnmarshaler = &ForbidigoPattern{}
// ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support.
// The YAML field names must match what forbidigo expects.
type ForbidigoPattern struct {
// patternString gets populated when the config contains a string as entry in ForbidigoSettings.Forbid[]
// because ForbidigoPattern implements encoding.TextUnmarshaler
// and the reader uses the mapstructure.TextUnmarshallerHookFunc as decoder hook.
//
// If the entry is a map, then the other fields are set as usual by mapstructure.
patternString string
Pattern string `yaml:"p" mapstructure:"p"`
Package string `yaml:"pkg,omitempty" mapstructure:"pkg,omitempty"`
Msg string `yaml:"msg,omitempty" mapstructure:"msg,omitempty"`
}
func (p *ForbidigoPattern) UnmarshalText(text []byte) error {
// Validation happens when instantiating forbidigo.
p.patternString = string(text)
return nil
}
// MarshalString converts the pattern into a string as needed by forbidigo.NewLinter.
//
// MarshalString is intentionally not called MarshalText,
// although it has the same signature
// because implementing encoding.TextMarshaler led to infinite recursion when yaml.Marshal called MarshalText.
func (p *ForbidigoPattern) MarshalString() ([]byte, error) {
if p.patternString != "" {
return []byte(p.patternString), nil
}
return yaml.Marshal(p)
}
type FunlenSettings struct {
Lines int
Statements int
IgnoreComments bool `mapstructure:"ignore-comments"`
}
type GciSettings struct {
LocalPrefixes string `mapstructure:"local-prefixes"` // Deprecated
Sections []string `mapstructure:"sections"`
SkipGenerated bool `mapstructure:"skip-generated"`
CustomOrder bool `mapstructure:"custom-order"`
}
type GinkgoLinterSettings struct {
SuppressLenAssertion bool `mapstructure:"suppress-len-assertion"`
SuppressNilAssertion bool `mapstructure:"suppress-nil-assertion"`
SuppressErrAssertion bool `mapstructure:"suppress-err-assertion"`
SuppressCompareAssertion bool `mapstructure:"suppress-compare-assertion"`
SuppressAsyncAssertion bool `mapstructure:"suppress-async-assertion"`
SuppressTypeCompareWarning bool `mapstructure:"suppress-type-compare-assertion"`
ForbidFocusContainer bool `mapstructure:"forbid-focus-container"`
AllowHaveLenZero bool `mapstructure:"allow-havelen-zero"`
}
type GocognitSettings struct {
MinComplexity int `mapstructure:"min-complexity"`
}
type GoConstSettings struct {
IgnoreStrings string `mapstructure:"ignore-strings"`
IgnoreTests bool `mapstructure:"ignore-tests"`
MatchWithConstants bool `mapstructure:"match-constant"`
MinStringLen int `mapstructure:"min-len"`
MinOccurrencesCount int `mapstructure:"min-occurrences"`
ParseNumbers bool `mapstructure:"numbers"`
NumberMin int `mapstructure:"min"`
NumberMax int `mapstructure:"max"`
IgnoreCalls bool `mapstructure:"ignore-calls"`
}
type GoCriticSettings struct {
Go string `mapstructure:"-"`
EnabledChecks []string `mapstructure:"enabled-checks"`
DisabledChecks []string `mapstructure:"disabled-checks"`
EnabledTags []string `mapstructure:"enabled-tags"`
DisabledTags []string `mapstructure:"disabled-tags"`
SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
}
type GoCriticCheckSettings map[string]any
type GoCycloSettings struct {
MinComplexity int `mapstructure:"min-complexity"`
}
type GodotSettings struct {
Scope string `mapstructure:"scope"`
Exclude []string `mapstructure:"exclude"`
Capital bool `mapstructure:"capital"`
Period bool `mapstructure:"period"`
// Deprecated: use `Scope` instead
CheckAll bool `mapstructure:"check-all"`
}
type GodoxSettings struct {
Keywords []string
}
type GoFmtSettings struct {
Simplify bool
RewriteRules []GoFmtRewriteRule `mapstructure:"rewrite-rules"`
}
type GoFmtRewriteRule struct {
Pattern string
Replacement string
}
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"`
}
type GoHeaderSettings struct {
Values map[string]map[string]string `mapstructure:"values"`
Template string `mapstructure:"template"`
TemplatePath string `mapstructure:"template-path"`
}
type GoImportsSettings struct {
LocalPrefixes string `mapstructure:"local-prefixes"`
}
type GoLintSettings struct {
MinConfidence float64 `mapstructure:"min-confidence"`
}
type GoMndSettings struct {
Settings map[string]map[string]any // Deprecated
Checks []string `mapstructure:"checks"`
IgnoredNumbers []string `mapstructure:"ignored-numbers"`
IgnoredFiles []string `mapstructure:"ignored-files"`
IgnoredFunctions []string `mapstructure:"ignored-functions"`
}
type GoModDirectivesSettings struct {
ReplaceAllowList []string `mapstructure:"replace-allow-list"`
ReplaceLocal bool `mapstructure:"replace-local"`
ExcludeForbidden bool `mapstructure:"exclude-forbidden"`
RetractAllowNoExplanation bool `mapstructure:"retract-allow-no-explanation"`
}
type GoModGuardSettings struct {
Allowed struct {
Modules []string `mapstructure:"modules"`
Domains []string `mapstructure:"domains"`
} `mapstructure:"allowed"`
Blocked struct {
Modules []map[string]struct {
Recommendations []string `mapstructure:"recommendations"`
Reason string `mapstructure:"reason"`
} `mapstructure:"modules"`
Versions []map[string]struct {
Version string `mapstructure:"version"`
Reason string `mapstructure:"reason"`
} `mapstructure:"versions"`
LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
} `mapstructure:"blocked"`
}
type GoSecSettings struct {
Includes []string `mapstructure:"includes"`
Excludes []string `mapstructure:"excludes"`
Severity string `mapstructure:"severity"`
Confidence string `mapstructure:"confidence"`
ExcludeGenerated bool `mapstructure:"exclude-generated"`
Config map[string]any `mapstructure:"config"`
Concurrency int `mapstructure:"concurrency"`
}
type GosmopolitanSettings struct {
AllowTimeLocal bool `mapstructure:"allow-time-local"`
EscapeHatches []string `mapstructure:"escape-hatches"`
IgnoreTests bool `mapstructure:"ignore-tests"`
WatchForScripts []string `mapstructure:"watch-for-scripts"`
}
type GovetSettings struct {
Go string `mapstructure:"-"`
CheckShadowing bool `mapstructure:"check-shadowing"`
Settings map[string]map[string]any
Enable []string
Disable []string
EnableAll bool `mapstructure:"enable-all"`
DisableAll bool `mapstructure:"disable-all"`
}
func (cfg *GovetSettings) Validate() error {
if cfg.EnableAll && cfg.DisableAll {
return errors.New("enable-all and disable-all can't be combined")
}
if cfg.EnableAll && len(cfg.Enable) != 0 {
return errors.New("enable-all and enable can't be combined")
}
if cfg.DisableAll && len(cfg.Disable) != 0 {
return errors.New("disable-all and disable can't be combined")
}
return nil
}
type GrouperSettings struct {
ConstRequireSingleConst bool `mapstructure:"const-require-single-const"`
ConstRequireGrouping bool `mapstructure:"const-require-grouping"`
ImportRequireSingleImport bool `mapstructure:"import-require-single-import"`
ImportRequireGrouping bool `mapstructure:"import-require-grouping"`
TypeRequireSingleType bool `mapstructure:"type-require-single-type"`
TypeRequireGrouping bool `mapstructure:"type-require-grouping"`
VarRequireSingleVar bool `mapstructure:"var-require-single-var"`
VarRequireGrouping bool `mapstructure:"var-require-grouping"`
}
type IfshortSettings struct {
MaxDeclLines int `mapstructure:"max-decl-lines"`
MaxDeclChars int `mapstructure:"max-decl-chars"`
}
type ImportAsSettings struct {
Alias []ImportAsAlias
NoUnaliased bool `mapstructure:"no-unaliased"`
NoExtraAliases bool `mapstructure:"no-extra-aliases"`
}
type ImportAsAlias struct {
Pkg string
Alias string
}
type INamedParamSettings struct {
SkipSingleParam bool `mapstructure:"skip-single-param"`
}
type InterfaceBloatSettings struct {
Max int `mapstructure:"max"`
}
type IreturnSettings struct {
Allow []string `mapstructure:"allow"`
Reject []string `mapstructure:"reject"`
}
type LllSettings struct {
LineLength int `mapstructure:"line-length"`
TabWidth int `mapstructure:"tab-width"`
}
type LoggerCheckSettings struct {
Kitlog bool `mapstructure:"kitlog"`
Klog bool `mapstructure:"klog"`
Logr bool `mapstructure:"logr"`
Zap bool `mapstructure:"zap"`
RequireStringKey bool `mapstructure:"require-string-key"`
NoPrintfLike bool `mapstructure:"no-printf-like"`
Rules []string `mapstructure:"rules"`
}
type MaintIdxSettings struct {
Under int `mapstructure:"under"`
}
type MakezeroSettings struct {
Always bool
}
type MalignedSettings struct {
SuggestNewOrder bool `mapstructure:"suggest-new"`
}
type MisspellSettings struct {
Mode string `mapstructure:"mode"`
Locale string
// TODO(ldez): v2 the option must be renamed to `IgnoredRules`.
IgnoreWords []string `mapstructure:"ignore-words"`
}
type MustTagSettings struct {
Functions []struct {
Name string `mapstructure:"name"`
Tag string `mapstructure:"tag"`
ArgPos int `mapstructure:"arg-pos"`
} `mapstructure:"functions"`
}
type NakedretSettings struct {
MaxFuncLines int `mapstructure:"max-func-lines"`
}
type NestifSettings struct {
MinComplexity int `mapstructure:"min-complexity"`
}
type NilNilSettings struct {
CheckedTypes []string `mapstructure:"checked-types"`
}
type NlreturnSettings struct {
BlockSize int `mapstructure:"block-size"`
}
type NoLintLintSettings struct {
RequireExplanation bool `mapstructure:"require-explanation"`
RequireSpecific bool `mapstructure:"require-specific"`
AllowNoExplanation []string `mapstructure:"allow-no-explanation"`
AllowUnused bool `mapstructure:"allow-unused"`
}
type NoNamedReturnsSettings struct {
ReportErrorInDefer bool `mapstructure:"report-error-in-defer"`
}
type ParallelTestSettings struct {
IgnoreMissing bool `mapstructure:"ignore-missing"`
IgnoreMissingSubtests bool `mapstructure:"ignore-missing-subtests"`
}
type PerfSprintSettings struct {
IntConversion bool `mapstructure:"int-conversion"`
ErrError bool `mapstructure:"err-error"`
ErrorF bool `mapstructure:"errorf"`
SprintF1 bool `mapstructure:"sprintf1"`
}
type PreallocSettings struct {
Simple bool
RangeLoops bool `mapstructure:"range-loops"`
ForLoops bool `mapstructure:"for-loops"`
}
type PredeclaredSettings struct {
Ignore string `mapstructure:"ignore"`
Qualified bool `mapstructure:"q"`
}
type PromlinterSettings struct {
Strict bool `mapstructure:"strict"`
DisabledLinters []string `mapstructure:"disabled-linters"`
}
type ProtoGetterSettings struct {
SkipGeneratedBy []string `mapstructure:"skip-generated-by"`
SkipFiles []string `mapstructure:"skip-files"`
SkipAnyGenerated bool `mapstructure:"skip-any-generated"`
}
type ReassignSettings struct {
Patterns []string `mapstructure:"patterns"`
}
type ReviveSettings struct {
MaxOpenFiles int `mapstructure:"max-open-files"`
IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
Confidence float64
Severity string
EnableAllRules bool `mapstructure:"enable-all-rules"`
Rules []struct {
Name string
Arguments []any
Severity string
Disabled bool
}
ErrorCode int `mapstructure:"error-code"`
WarningCode int `mapstructure:"warning-code"`
Directives []struct {
Name string
Severity string
}
}
type RowsErrCheckSettings struct {
Packages []string
}
type SlogLintSettings struct {
NoMixedArgs bool `mapstructure:"no-mixed-args"`
KVOnly bool `mapstructure:"kv-only"`
AttrOnly bool `mapstructure:"attr-only"`
ContextOnly bool `mapstructure:"context-only"`
StaticMsg bool `mapstructure:"static-msg"`
NoRawKeys bool `mapstructure:"no-raw-keys"`
KeyNamingCase string `mapstructure:"key-naming-case"`
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
}
type StaticCheckSettings struct {
CommonStaticCheckSettings `mapstructure:",squash"`
Initialisms []string `mapstructure:"initialisms"`
DotImportWhitelist []string `mapstructure:"dot-import-whitelist"`
HTTPStatusCodeWhitelist []string `mapstructure:"http-status-code-whitelist"`
}
type CommonStaticCheckSettings struct {
// Deprecated: use the global `run.go` instead.
GoVersion string `mapstructure:"go"`
Checks []string `mapstructure:"checks"`
}
func (s *StaticCheckSettings) HasConfiguration() bool {
return len(s.Initialisms) > 0 || len(s.HTTPStatusCodeWhitelist) > 0 || len(s.DotImportWhitelist) > 0 || len(s.Checks) > 0
}
func (s *CommonStaticCheckSettings) GetGoVersion() string {
var goVersion string
if s != nil {
goVersion = s.GoVersion
}
if goVersion != "" {
return goVersion
}
return "1.17"
}
type StructCheckSettings struct {
CheckExportedFields bool `mapstructure:"exported-fields"`
}
type TagAlignSettings struct {
Align bool `mapstructure:"align"`
Sort bool `mapstructure:"sort"`
Order []string `mapstructure:"order"`
Strict bool `mapstructure:"strict"`
}
type TagliatelleSettings struct {
Case struct {
Rules map[string]string
UseFieldName bool `mapstructure:"use-field-name"`
}
}
type TestifylintSettings struct {
EnableAll bool `mapstructure:"enable-all"`
DisableAll bool `mapstructure:"disable-all"`
EnabledCheckers []string `mapstructure:"enable"`
DisabledCheckers []string `mapstructure:"disable"`
ExpectedActual struct {
ExpVarPattern string `mapstructure:"pattern"`
} `mapstructure:"expected-actual"`
RequireError struct {
FnPattern string `mapstructure:"fn-pattern"`
} `mapstructure:"require-error"`
SuiteExtraAssertCall struct {
Mode string `mapstructure:"mode"`
} `mapstructure:"suite-extra-assert-call"`
}
type TestpackageSettings struct {
SkipRegexp string `mapstructure:"skip-regexp"`
AllowPackages []string `mapstructure:"allow-packages"`
}
type ThelperSettings struct {
Test ThelperOptions `mapstructure:"test"`
Fuzz ThelperOptions `mapstructure:"fuzz"`
Benchmark ThelperOptions `mapstructure:"benchmark"`
TB ThelperOptions `mapstructure:"tb"`
}
type ThelperOptions struct {
First *bool `mapstructure:"first"`
Name *bool `mapstructure:"name"`
Begin *bool `mapstructure:"begin"`
}
type TenvSettings struct {
All bool `mapstructure:"all"`
}
type UseStdlibVarsSettings struct {
HTTPMethod bool `mapstructure:"http-method"`
HTTPStatusCode bool `mapstructure:"http-status-code"`
TimeWeekday bool `mapstructure:"time-weekday"`
TimeMonth bool `mapstructure:"time-month"`
TimeLayout bool `mapstructure:"time-layout"`
CryptoHash bool `mapstructure:"crypto-hash"`
DefaultRPCPath bool `mapstructure:"default-rpc-path"`
OSDevNull bool `mapstructure:"os-dev-null"`
SQLIsolationLevel bool `mapstructure:"sql-isolation-level"`
TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"`
ConstantKind bool `mapstructure:"constant-kind"`
SyslogPriority bool `mapstructure:"syslog-priority"`
}
type UnparamSettings struct {
CheckExported bool `mapstructure:"check-exported"`
// Deprecated
Algo string
}
type UnusedSettings struct {
FieldWritesAreUses bool `mapstructure:"field-writes-are-uses"`
PostStatementsAreReads bool `mapstructure:"post-statements-are-reads"`
ExportedIsUsed bool `mapstructure:"exported-is-used"`
ExportedFieldsAreUsed bool `mapstructure:"exported-fields-are-used"`
ParametersAreUsed bool `mapstructure:"parameters-are-used"`
LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"`
GeneratedIsUsed bool `mapstructure:"generated-is-used"`
}
type VarCheckSettings struct {
CheckExportedFields bool `mapstructure:"exported-fields"`
}
type VarnamelenSettings struct {
MaxDistance int `mapstructure:"max-distance"`
MinNameLength int `mapstructure:"min-name-length"`
CheckReceiver bool `mapstructure:"check-receiver"`
CheckReturn bool `mapstructure:"check-return"`
CheckTypeParam bool `mapstructure:"check-type-param"`
IgnoreNames []string `mapstructure:"ignore-names"`
IgnoreTypeAssertOk bool `mapstructure:"ignore-type-assert-ok"`
IgnoreMapIndexOk bool `mapstructure:"ignore-map-index-ok"`
IgnoreChanRecvOk bool `mapstructure:"ignore-chan-recv-ok"`
IgnoreDecls []string `mapstructure:"ignore-decls"`
}
type WhitespaceSettings struct {
MultiIf bool `mapstructure:"multi-if"`
MultiFunc bool `mapstructure:"multi-func"`
}
type WrapcheckSettings struct {
// TODO(ldez): v2 the options must be renamed to use hyphen.
IgnoreSigs []string `mapstructure:"ignoreSigs"`
IgnoreSigRegexps []string `mapstructure:"ignoreSigRegexps"`
IgnorePackageGlobs []string `mapstructure:"ignorePackageGlobs"`
IgnoreInterfaceRegexps []string `mapstructure:"ignoreInterfaceRegexps"`
}
type WSLSettings struct {
StrictAppend bool `mapstructure:"strict-append"`
AllowAssignAndCallCuddle bool `mapstructure:"allow-assign-and-call"`
AllowAssignAndAnythingCuddle bool `mapstructure:"allow-assign-and-anything"`
AllowMultiLineAssignCuddle bool `mapstructure:"allow-multiline-assign"`
ForceCaseTrailingWhitespaceLimit int `mapstructure:"force-case-trailing-whitespace"`
AllowTrailingComment bool `mapstructure:"allow-trailing-comment"`
AllowSeparatedLeadingComment bool `mapstructure:"allow-separated-leading-comment"`
AllowCuddleDeclaration bool `mapstructure:"allow-cuddle-declarations"`
AllowCuddleWithCalls []string `mapstructure:"allow-cuddle-with-calls"`
AllowCuddleWithRHS []string `mapstructure:"allow-cuddle-with-rhs"`
ForceCuddleErrCheckAndAssign bool `mapstructure:"force-err-cuddling"`
ErrorVariableNames []string `mapstructure:"error-variable-names"`
ForceExclusiveShortDeclarations bool `mapstructure:"force-short-decl-cuddling"`
}
// CustomLinterSettings encapsulates the meta-data of a private linter.
// For example, a private linter may be added to the golangci config file as shown below.
//
// linters-settings:
// custom:
// example:
// path: /example.so
// description: The description of the linter
// original-url: github.com/golangci/example-linter
type CustomLinterSettings struct {
// Path to a plugin *.so file that implements the private linter.
Path string
// Description describes the purpose of the private linter.
Description string
// OriginalURL The URL containing the source code for the private linter.
OriginalURL string `mapstructure:"original-url"`
// Settings plugin settings only work with linterdb.PluginConstructor symbol.
Settings any
}