Merge pull request #134161 from skitt/disable-gocritic

Disable unwanted gocritic checks instead of filtering them
This commit is contained in:
Kubernetes Prow Robot
2025-10-22 10:32:41 -07:00
committed by GitHub
2 changed files with 38 additions and 16 deletions

View File

@@ -126,12 +126,7 @@ linters:
- linters:
- gocritic
text: "append result not assigned to the same slice|put a space between `//` and comment text|sloppyLen|elseif|should rewrite switch statement to if statement|regexpMust|wrapperFunc: use strings.ReplaceAll|singleCaseSwitch|deprecatedComment|exitAfterDefer|captLocal|unlambda|underef|unslice|valSwap|typeSwitchVar"
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008918
- linters:
- gocritic
text: "assignOp:"
text: "wrapperFunc: use strings.ReplaceAll|should rewrite switch statement to if statement"
# Kube-API-Linter should only be run on the API definitions
- linters:
@@ -391,9 +386,25 @@ linters:
pkg: ^k8s\.io/component-base/featuregate$
msg: should not use Add, use AddVersioned instead
gocritic:
enabled-checks:
- equalFold
enabled-checks: # These are in addition to the default checks - see https://golangci-lint.run/docs/linters/configuration/#gocritic
- boolExprSimplify
- equalFold
disabled-checks: # This disables checks that are enabled by default (this can be combined with enabled-checks, contrary to the docs)
- appendAssign
- assignOp # https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008918
- captLocal
- commentFormatting
- deprecatedComment
- elseif
# The following have few (single-digit) occurrences left in k/k and wouldn't be too onerous to enable
- exitAfterDefer
- regexpMust
- sloppyLen
- typeSwitchVar
- underef
- unlambda
- unslice
- valSwap
revive:
# Only these rules are enabled.
rules:

View File

@@ -141,12 +141,7 @@ linters:
- linters:
- gocritic
text: "append result not assigned to the same slice|put a space between `//` and comment text|sloppyLen|elseif|should rewrite switch statement to if statement|regexpMust|wrapperFunc: use strings.ReplaceAll|singleCaseSwitch|deprecatedComment|exitAfterDefer|captLocal|unlambda|underef|unslice|valSwap|typeSwitchVar"
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008918
- linters:
- gocritic
text: "assignOp:"
text: "wrapperFunc: use strings.ReplaceAll|should rewrite switch statement to if statement"
{{- end}}
@@ -238,9 +233,25 @@ linters:
{{- end}}
{{- if .Base }}
gocritic:
enabled-checks:
- equalFold
enabled-checks: # These are in addition to the default checks - see https://golangci-lint.run/docs/linters/configuration/#gocritic
- boolExprSimplify
- equalFold
disabled-checks: # This disables checks that are enabled by default (this can be combined with enabled-checks, contrary to the docs)
- appendAssign
- assignOp # https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008918
- captLocal
- commentFormatting
- deprecatedComment
- elseif
# The following have few (single-digit) occurrences left in k/k and wouldn't be too onerous to enable
- exitAfterDefer
- regexpMust
- sloppyLen
- typeSwitchVar
- underef
- unlambda
- unslice
- valSwap
{{- end}}
revive:
# Only these rules are enabled.