@@ -24,6 +24,7 @@ type Manager struct {
24
24
25
25
func NewManager (cfg * config.Config , log logutils.Log ) * Manager {
26
26
m := & Manager {cfg : cfg , log : log }
27
+
27
28
nameToLCs := make (map [string ][]* linter.Config )
28
29
for _ , lc := range m .GetAllSupportedLinterConfigs () {
29
30
for _ , name := range lc .AllNames () {
@@ -32,6 +33,7 @@ func NewManager(cfg *config.Config, log logutils.Log) *Manager {
32
33
}
33
34
34
35
m .nameToLCs = nameToLCs
36
+
35
37
return m
36
38
}
37
39
@@ -87,17 +89,6 @@ func (m Manager) GetLinterConfigs(name string) []*linter.Config {
87
89
return m .nameToLCs [name ]
88
90
}
89
91
90
- func enableLinterConfigs (lcs []* linter.Config , isEnabled func (lc * linter.Config ) bool ) []* linter.Config {
91
- var ret []* linter.Config
92
- for _ , lc := range lcs {
93
- lc := lc
94
- lc .EnabledByDefault = isEnabled (lc )
95
- ret = append (ret , lc )
96
- }
97
-
98
- return ret
99
- }
100
-
101
92
//nolint:funlen
102
93
func (m Manager ) GetAllSupportedLinterConfigs () []* linter.Config {
103
94
var (
@@ -289,7 +280,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
289
280
290
281
// The linters are sorted in the alphabetical order (case-insensitive).
291
282
// When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint.
292
- lcs := []* linter.Config {
283
+ return []* linter.Config {
293
284
linter .NewConfig (golinters .NewAsasalint (asasalintCfg )).
294
285
WithSince ("1.47.0" ).
295
286
WithPresets (linter .PresetBugs ).
@@ -370,6 +361,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
370
361
WithURL ("https://github.com/charithe/durationcheck" ),
371
362
372
363
linter .NewConfig (golinters .NewErrcheck (errcheckCfg )).
364
+ WithEnabledByDefault ().
373
365
WithSince ("v1.0.0" ).
374
366
WithLoadForGoAnalysis ().
375
367
WithPresets (linter .PresetBugs , linter .PresetError ).
@@ -566,6 +558,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
566
558
WithAlternativeNames ("gas" ),
567
559
568
560
linter .NewConfig (golinters .NewGosimple (gosimpleCfg )).
561
+ WithEnabledByDefault ().
569
562
WithSince ("v1.20.0" ).
570
563
WithLoadForGoAnalysis ().
571
564
WithPresets (linter .PresetStyle ).
@@ -579,6 +572,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
579
572
WithURL ("https://github.com/xen0n/gosmopolitan" ),
580
573
581
574
linter .NewConfig (golinters .NewGovet (govetCfg )).
575
+ WithEnabledByDefault ().
582
576
WithSince ("v1.0.0" ).
583
577
WithLoadForGoAnalysis ().
584
578
WithPresets (linter .PresetBugs , linter .PresetMetaLinter ).
@@ -603,6 +597,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
603
597
WithURL ("https://github.com/julz/importas" ),
604
598
605
599
linter .NewConfig (golinters .NewIneffassign ()).
600
+ WithEnabledByDefault ().
606
601
WithSince ("v1.0.0" ).
607
602
WithPresets (linter .PresetUnused ).
608
603
WithURL ("https://github.com/gordonklaus/ineffassign" ),
@@ -774,6 +769,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
774
769
WithURL ("https://github.com/ryanrolds/sqlclosecheck" ),
775
770
776
771
linter .NewConfig (golinters .NewStaticcheck (staticcheckCfg )).
772
+ WithEnabledByDefault ().
777
773
WithSince ("v1.0.0" ).
778
774
WithLoadForGoAnalysis ().
779
775
WithPresets (linter .PresetBugs , linter .PresetMetaLinter ).
@@ -833,6 +829,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
833
829
WithURL ("https://github.com/moricho/tparallel" ),
834
830
835
831
linter .NewConfig (golinters .NewTypecheck ()).
832
+ WithEnabledByDefault ().
836
833
WithSince ("v1.3.0" ).
837
834
WithLoadForGoAnalysis ().
838
835
WithPresets (linter .PresetBugs ).
@@ -851,6 +848,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
851
848
WithURL ("https://github.com/mvdan/unparam" ),
852
849
853
850
linter .NewConfig (golinters .NewUnused (unusedCfg )).
851
+ WithEnabledByDefault ().
854
852
WithSince ("v1.20.0" ).
855
853
WithLoadForGoAnalysis ().
856
854
WithPresets (linter .PresetUnused ).
@@ -912,19 +910,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
912
910
WithLoadForGoAnalysis ().
913
911
WithURL ("https://github.com/ykadowak/zerologlint" ),
914
912
}
915
-
916
- enabledByDefault := map [string ]bool {
917
- golinters .NewGovet (nil ).Name (): true ,
918
- golinters .NewErrcheck (errcheckCfg ).Name (): true ,
919
- golinters .NewStaticcheck (staticcheckCfg ).Name (): true ,
920
- golinters .NewUnused (unusedCfg ).Name (): true ,
921
- golinters .NewGosimple (gosimpleCfg ).Name (): true ,
922
- golinters .NewIneffassign ().Name (): true ,
923
- golinters .NewTypecheck ().Name (): true ,
924
- }
925
- return enableLinterConfigs (lcs , func (lc * linter.Config ) bool {
926
- return enabledByDefault [lc .Name ()]
927
- })
928
913
}
929
914
930
915
func (m Manager ) GetAllEnabledByDefaultLinters () []* linter.Config {
@@ -979,10 +964,12 @@ func (m Manager) loadCustomLinterConfig(name string, settings config.CustomLinte
979
964
settings .Description ,
980
965
analyzer .GetAnalyzers (),
981
966
nil ).WithLoadMode (goanalysis .LoadModeTypesInfo )
982
- linterConfig := linter .NewConfig (customLinter )
983
- linterConfig .EnabledByDefault = true
984
- linterConfig .IsSlow = false
985
- linterConfig .WithURL (settings .OriginalURL )
967
+
968
+ linterConfig := linter .NewConfig (customLinter ).
969
+ WithEnabledByDefault ().
970
+ WithLoadForGoAnalysis ().
971
+ WithURL (settings .OriginalURL )
972
+
986
973
return linterConfig , nil
987
974
}
988
975
0 commit comments