@@ -24,6 +24,7 @@ type Manager struct {
2424
2525func NewManager (cfg * config.Config , log logutils.Log ) * Manager {
2626 m := & Manager {cfg : cfg , log : log }
27+
2728 nameToLCs := make (map [string ][]* linter.Config )
2829 for _ , lc := range m .GetAllSupportedLinterConfigs () {
2930 for _ , name := range lc .AllNames () {
@@ -32,6 +33,7 @@ func NewManager(cfg *config.Config, log logutils.Log) *Manager {
3233 }
3334
3435 m .nameToLCs = nameToLCs
36+
3537 return m
3638}
3739
@@ -87,17 +89,6 @@ func (m Manager) GetLinterConfigs(name string) []*linter.Config {
8789 return m .nameToLCs [name ]
8890}
8991
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-
10192//nolint:funlen
10293func (m Manager ) GetAllSupportedLinterConfigs () []* linter.Config {
10394 var (
@@ -289,7 +280,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
289280
290281 // The linters are sorted in the alphabetical order (case-insensitive).
291282 // 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 {
293284 linter .NewConfig (golinters .NewAsasalint (asasalintCfg )).
294285 WithSince ("1.47.0" ).
295286 WithPresets (linter .PresetBugs ).
@@ -370,6 +361,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
370361 WithURL ("https://github.com/charithe/durationcheck" ),
371362
372363 linter .NewConfig (golinters .NewErrcheck (errcheckCfg )).
364+ WithEnabledByDefault ().
373365 WithSince ("v1.0.0" ).
374366 WithLoadForGoAnalysis ().
375367 WithPresets (linter .PresetBugs , linter .PresetError ).
@@ -566,6 +558,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
566558 WithAlternativeNames ("gas" ),
567559
568560 linter .NewConfig (golinters .NewGosimple (gosimpleCfg )).
561+ WithEnabledByDefault ().
569562 WithSince ("v1.20.0" ).
570563 WithLoadForGoAnalysis ().
571564 WithPresets (linter .PresetStyle ).
@@ -579,6 +572,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
579572 WithURL ("https://github.com/xen0n/gosmopolitan" ),
580573
581574 linter .NewConfig (golinters .NewGovet (govetCfg )).
575+ WithEnabledByDefault ().
582576 WithSince ("v1.0.0" ).
583577 WithLoadForGoAnalysis ().
584578 WithPresets (linter .PresetBugs , linter .PresetMetaLinter ).
@@ -603,6 +597,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
603597 WithURL ("https://github.com/julz/importas" ),
604598
605599 linter .NewConfig (golinters .NewIneffassign ()).
600+ WithEnabledByDefault ().
606601 WithSince ("v1.0.0" ).
607602 WithPresets (linter .PresetUnused ).
608603 WithURL ("https://github.com/gordonklaus/ineffassign" ),
@@ -774,6 +769,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
774769 WithURL ("https://github.com/ryanrolds/sqlclosecheck" ),
775770
776771 linter .NewConfig (golinters .NewStaticcheck (staticcheckCfg )).
772+ WithEnabledByDefault ().
777773 WithSince ("v1.0.0" ).
778774 WithLoadForGoAnalysis ().
779775 WithPresets (linter .PresetBugs , linter .PresetMetaLinter ).
@@ -833,6 +829,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
833829 WithURL ("https://github.com/moricho/tparallel" ),
834830
835831 linter .NewConfig (golinters .NewTypecheck ()).
832+ WithEnabledByDefault ().
836833 WithSince ("v1.3.0" ).
837834 WithLoadForGoAnalysis ().
838835 WithPresets (linter .PresetBugs ).
@@ -851,6 +848,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
851848 WithURL ("https://github.com/mvdan/unparam" ),
852849
853850 linter .NewConfig (golinters .NewUnused (unusedCfg )).
851+ WithEnabledByDefault ().
854852 WithSince ("v1.20.0" ).
855853 WithLoadForGoAnalysis ().
856854 WithPresets (linter .PresetUnused ).
@@ -912,19 +910,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
912910 WithLoadForGoAnalysis ().
913911 WithURL ("https://github.com/ykadowak/zerologlint" ),
914912 }
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- })
928913}
929914
930915func (m Manager ) GetAllEnabledByDefaultLinters () []* linter.Config {
@@ -979,10 +964,12 @@ func (m Manager) loadCustomLinterConfig(name string, settings config.CustomLinte
979964 settings .Description ,
980965 analyzer .GetAnalyzers (),
981966 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+
986973 return linterConfig , nil
987974}
988975
0 commit comments