Skip to content

Commit 43db87a

Browse files
committed
chore: annotate and re-organize configuration structures
1 parent 65b1c25 commit 43db87a

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

pkg/config/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import (
1212
type Config struct {
1313
cfgDir string // The directory containing the golangci-lint config file.
1414

15-
Run Run
15+
Run Run `mapstructure:"run"`
1616

17-
Output Output
17+
Output Output `mapstructure:"output"`
1818

1919
LintersSettings LintersSettings `mapstructure:"linters-settings"`
20-
Linters Linters
21-
Issues Issues
22-
Severity Severity
20+
Linters Linters `mapstructure:"linters"`
21+
Issues Issues `mapstructure:"issues"`
22+
Severity Severity `mapstructure:"severity"`
2323

24-
Version Version
24+
Version Version // Flag only. // TODO(ldez) only used by the version command.
2525

26-
InternalCmdTest bool `mapstructure:"internal-cmd-test"` // Option is used only for testing golangci-lint command, don't use it
26+
InternalCmdTest bool // Option is used only for testing golangci-lint command, don't use it
2727
InternalTest bool // Option is used only for testing golangci-lint code, don't use it
2828
}
2929

pkg/config/output.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var OutFormats = []string{
2828
}
2929

3030
type Output struct {
31-
Format string
31+
Format string `mapstructure:"format"`
3232
PrintIssuedLine bool `mapstructure:"print-issued-lines"`
3333
PrintLinterName bool `mapstructure:"print-linter-name"`
3434
UniqByLine bool `mapstructure:"uniq-by-line"`
@@ -37,5 +37,5 @@ type Output struct {
3737
PathPrefix string `mapstructure:"path-prefix"`
3838

3939
// only work with CLI flags because the setup of logs is done before the config file parsing.
40-
Color string
40+
Color string // Flag only.
4141
}

pkg/config/run.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@ import "time"
44

55
// Run encapsulates the config options for running the linter analysis.
66
type Run struct {
7-
IsVerbose bool `mapstructure:"verbose"`
8-
Silent bool
9-
CPUProfilePath string
10-
MemProfilePath string
11-
TracePath string
12-
Concurrency int
13-
PrintResourcesUsage bool `mapstructure:"print-resources-usage"`
7+
Timeout time.Duration `mapstructure:"timeout"`
148

15-
Config string // The path to the golangci config file, as specified with the --config argument.
16-
NoConfig bool
17-
18-
Args []string
9+
Concurrency int `mapstructure:"concurrency"`
1910

2011
Go string `mapstructure:"go"`
2112

@@ -25,9 +16,6 @@ type Run struct {
2516
ExitCodeIfIssuesFound int `mapstructure:"issues-exit-code"`
2617
AnalyzeTests bool `mapstructure:"tests"`
2718

28-
Timeout time.Duration
29-
30-
PrintVersion bool
3119
SkipFiles []string `mapstructure:"skip-files"`
3220
SkipDirs []string `mapstructure:"skip-dirs"`
3321
UseDefaultSkipDirs bool `mapstructure:"skip-dirs-use-default"`
@@ -36,4 +24,21 @@ type Run struct {
3624
AllowSerialRunners bool `mapstructure:"allow-serial-runners"`
3725

3826
ShowStats bool `mapstructure:"show-stats"`
27+
28+
// --- Flags only section.
29+
30+
IsVerbose bool `mapstructure:"verbose"` // Flag only
31+
32+
PrintVersion bool // Flag only. (used by the root command)
33+
34+
CPUProfilePath string // Flag only.
35+
MemProfilePath string // Flag only.
36+
TracePath string // Flag only.
37+
38+
PrintResourcesUsage bool `mapstructure:"print-resources-usage"` // Flag only. // TODO(ldez) need to be enforced.
39+
40+
Config string // Flag only. The path to the golangci config file, as specified with the --config argument.
41+
NoConfig bool // Flag only.
42+
43+
Args []string // Flag only. // TODO(ldez) identify the real need and usage.
3944
}

0 commit comments

Comments
 (0)