Skip to content

Commit

Permalink
gocritic: support of enable-all and disable-all options (#4335)
Browse files Browse the repository at this point in the history
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
  • Loading branch information
Antonboom and ldez committed Feb 19, 2024
1 parent b07bd18 commit c65868c
Show file tree
Hide file tree
Showing 12 changed files with 794 additions and 399 deletions.
20 changes: 15 additions & 5 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,22 +529,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 @@ -460,7 +460,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

0 comments on commit c65868c

Please sign in to comment.