Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gocritic: support of enable-all and disable-all options #4335

Merged
merged 10 commits into from
Feb 19, 2024
20 changes: 15 additions & 5 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -525,22 +525,32 @@ linters-settings:
ignore-strings: 'foo.+'

gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks'.
# See https://go-critic.github.io/overview#checks-overview.
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`.
# By default, list of stable checks is used.
# Disable all checks.
# Default: false
disable-all: true
# Which checks should be enabled in addition to default checks; can't be combined with 'disabled-checks'.
# By default, list of stable checks is used (https://go-critic.github.io/overview#checks-overview):
# appendAssign, argOrder, assignOp, badCall, badCond, captLocal, caseOrder, codegenComment, commentFormatting,
# defaultCaseOrder, deprecatedComment, dupArg, dupBranchBody, dupCase, dupSubExpr, elseif, exitAfterDefer,
# flagDeref, flagName, ifElseChain, mapKey, newDeref, offBy1, regexpMust, singleCaseSwitch, sloppyLen,
# sloppyTypeAssert, switchTrue, typeSwitchVar, underef, unlambda, unslice, valSwap, wrapperFunc
# To see which checks are enabled run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic`.
enabled-checks:
- nestingReduce
- unnamedResult
- ruleguard
- truncateCmp

# Enable all checks.
# Default: false
enable-all: true
# Which checks should be disabled; can't be combined with 'enabled-checks'.
# Default: []
disabled-checks:
- regexpMust

# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Enable multiple checks by tags in addition to default checks.
# Run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic` to see all tags and checks.
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
# Default: []
enabled-tags:
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ type GoConstSettings struct {

type GoCriticSettings struct {
Go string `mapstructure:"-"`
DisableAll bool `mapstructure:"disable-all"`
EnabledChecks []string `mapstructure:"enabled-checks"`
EnableAll bool `mapstructure:"enable-all"`
DisabledChecks []string `mapstructure:"disabled-checks"`
EnabledTags []string `mapstructure:"enabled-tags"`
DisabledTags []string `mapstructure:"disabled-tags"`
Expand Down
Loading
Loading