Skip to content

Commit

Permalink
fix: move show-stats field from run to output (#4439)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 4, 2024
1 parent a087808 commit 8f2459b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
7 changes: 3 additions & 4 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ run:
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
go: '1.19'

# Show statistics per linter.
# Default: false
show-stats: true


# output configuration options
output:
Expand Down Expand Up @@ -117,6 +113,9 @@ output:
# Default: false
sort-results: true

# Show statistics per linter.
# Default: false
show-stats: true

# All available settings of specific linters.
linters-settings:
Expand Down
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,30 @@ issues:
- gomnd

- path: pkg/golinters/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
linters: [staticcheck]
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
linters: [staticcheck]
text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead."

- path: pkg/golinters/gofumpt.go
linters: [staticcheck]
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
- path: pkg/golinters/staticcheck_common.go
linters: [staticcheck]
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
- path: pkg/lint/lintersdb/manager.go
linters: [staticcheck]
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."

- path: pkg/golinters/unused.go
linters: [gocritic]
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
- path: test/(fix|linters)_test.go
linters: [gocritic]
text: "string `gocritic.go` has 3 occurrences, make it a constant"

run:
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/flagsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
const allowSerialDesc = "Allow multiple golangci-lint instances running, but serialize them around a lock. " +
"If false (default) - golangci-lint exits with an error if it fails to acquire file lock on start."
internal.AddFlagAndBind(v, fs, fs.Bool, "allow-serial-runners", "run.allow-serial-runners", false, color.GreenString(allowSerialDesc))
internal.AddFlagAndBind(v, fs, fs.Bool, "show-stats", "run.show-stats", false, color.GreenString("Show statistics per linter"))
}

func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
Expand All @@ -71,6 +70,7 @@ func setupOutputFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
color.GreenString("Sort linter results"))
internal.AddFlagAndBind(v, fs, fs.String, "path-prefix", "output.path-prefix", "",
color.GreenString("Path prefix to add to output"))
internal.AddFlagAndBind(v, fs, fs.Bool, "show-stats", "output.show-stats", false, color.GreenString("Show statistics per linter"))
}

//nolint:gomnd
Expand Down
6 changes: 5 additions & 1 deletion pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ func (c *runCommand) setExitCodeIfIssuesFound(issues []result.Issue) {
}

func (c *runCommand) printStats(issues []result.Issue) {
if !c.cfg.Run.ShowStats {
if c.cfg.Run.ShowStats {
c.log.Warnf("The configuration option `run.show-stats` is deprecated, please use `output.show-stats`")
}

if !c.cfg.Run.ShowStats && !c.cfg.Output.ShowStats {
return
}

Expand Down
1 change: 1 addition & 0 deletions pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ type Output struct {
UniqByLine bool `mapstructure:"uniq-by-line"`
SortResults bool `mapstructure:"sort-results"`
PathPrefix string `mapstructure:"path-prefix"`
ShowStats bool `mapstructure:"show-stats"`
}
1 change: 1 addition & 0 deletions pkg/config/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Run struct {
AllowParallelRunners bool `mapstructure:"allow-parallel-runners"`
AllowSerialRunners bool `mapstructure:"allow-serial-runners"`

// Deprecated: use Output.ShowStats instead.
ShowStats bool `mapstructure:"show-stats"`

// It's obtain by flags and use for the tests and the context loader.
Expand Down

0 comments on commit 8f2459b

Please sign in to comment.