Skip to content

Commit 5a32c62

Browse files
committed
fix: refactor the configuration loading and parsing system
It's only a first step, must be rewrite in the future.
1 parent 1f10e86 commit 5a32c62

File tree

9 files changed

+435
-400
lines changed

9 files changed

+435
-400
lines changed

.golangci.reference.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ linters-settings:
11131113
makezero:
11141114
# Allow only slices initialized with a length of zero.
11151115
# Default: false
1116-
always: false
1116+
always: true
11171117

11181118
maligned:
11191119
# Print struct with more effective memory layout or not.

pkg/commands/executor.go

-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ func NewExecutor(version, commit, date string) *Executor {
117117
// recreate after getting config
118118
e.DBManager = lintersdb.NewManager(e.cfg, e.log).WithCustomLinters()
119119

120-
e.cfg.LintersSettings.Gocritic.InferEnabledChecks(e.log)
121-
if err = e.cfg.LintersSettings.Gocritic.Validate(e.log); err != nil {
122-
e.log.Fatalf("Invalid gocritic settings: %s", err)
123-
}
124-
125120
// Slice options must be explicitly set for proper merging of config and command-line options.
126121
fixSlicesFlags(e.runCmd.Flags())
127122
fixSlicesFlags(e.lintersCmd.Flags())

pkg/config/linters_settings.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ var defaultLintersSettings = LintersSettings{
4040
Gocognit: GocognitSettings{
4141
MinComplexity: 30,
4242
},
43-
Gocritic: GocriticSettings{
44-
SettingsPerCheck: map[string]GocriticCheckSettings{},
43+
Gocritic: GoCriticSettings{
44+
SettingsPerCheck: map[string]GoCriticCheckSettings{},
4545
},
4646
Godox: GodoxSettings{
4747
Keywords: []string{},
@@ -133,7 +133,7 @@ type LintersSettings struct {
133133
Gci GciSettings
134134
Gocognit GocognitSettings
135135
Goconst GoConstSettings
136-
Gocritic GocriticSettings
136+
Gocritic GoCriticSettings
137137
Gocyclo GoCycloSettings
138138
Godot GodotSettings
139139
Godox GodoxSettings
@@ -306,6 +306,16 @@ type GoConstSettings struct {
306306
IgnoreCalls bool `mapstructure:"ignore-calls"`
307307
}
308308

309+
type GoCriticSettings struct {
310+
EnabledChecks []string `mapstructure:"enabled-checks"`
311+
DisabledChecks []string `mapstructure:"disabled-checks"`
312+
EnabledTags []string `mapstructure:"enabled-tags"`
313+
DisabledTags []string `mapstructure:"disabled-tags"`
314+
SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
315+
}
316+
317+
type GoCriticCheckSettings map[string]interface{}
318+
309319
type GoCycloSettings struct {
310320
MinComplexity int `mapstructure:"min-complexity"`
311321
}

0 commit comments

Comments
 (0)