Merge pull request #130647 from alexandear/golangci-fix-forbidigo-settings

hack: fix settings for forbidigo linter
This commit is contained in:
Kubernetes Prow Robot 2025-03-11 19:47:52 -07:00 committed by GitHub
commit 6ef9938e4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 9 deletions

View File

@ -48,7 +48,7 @@ issues:
# Adding unversioned feature gates is allowed in tests
- linters:
- forbidigo
text: should not use MutableFeatureGate.Add, use AddVersioned instead
text: should not use Add, use AddVersioned instead
path: _test.go$
# The Kubernetes naming convention for conversion functions uses underscores
@ -205,8 +205,7 @@ linters-settings: # please keep this alphabetized
msg: should not be used because managedFields was removed
- p: \.Add$
pkg: ^k8s\.io/component-base/featuregate$
type: ^MutableFeatureGate$
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
msg: should not use Add, use AddVersioned instead
- p: ^gomega\.BeTrue$
pkg: ^github.com/onsi/gomega$
msg: "it does not produce a good failure message - use BeTrueBecause with an explicit printf-style failure message instead, or plain Go: if ... { ginkgo.Fail(...) }"

View File

@ -48,7 +48,7 @@ issues:
# Adding unversioned feature gates is allowed in tests
- linters:
- forbidigo
text: should not use MutableFeatureGate.Add, use AddVersioned instead
text: should not use Add, use AddVersioned instead
path: _test.go$
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
@ -271,8 +271,7 @@ linters-settings: # please keep this alphabetized
msg: should not be used because managedFields was removed
- p: \.Add$
pkg: ^k8s\.io/component-base/featuregate$
type: ^MutableFeatureGate$
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
msg: should not use Add, use AddVersioned instead
gocritic:
enabled-checks:
- equalFold

View File

@ -48,7 +48,7 @@ issues:
# Adding unversioned feature gates is allowed in tests
- linters:
- forbidigo
text: should not use MutableFeatureGate.Add, use AddVersioned instead
text: should not use Add, use AddVersioned instead
path: _test.go$
{{- if .Base}}
@ -223,8 +223,7 @@ linters-settings: # please keep this alphabetized
msg: should not be used because managedFields was removed
- p: \.Add$
pkg: ^k8s\.io/component-base/featuregate$
type: ^MutableFeatureGate$
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
msg: should not use Add, use AddVersioned instead
{{- if .Hints}}
- p: ^gomega\.BeTrue$
pkg: ^github.com/onsi/gomega$

View File

@ -129,6 +129,22 @@ if [ "${golangci_config}" ]; then
GOTOOLCHAIN="$(kube::golang::hack_tools_gotoolchain)" go -C "${KUBE_ROOT}/hack/tools" build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
fi
# Verify that the given config is valid. "golangci-lint run" does not
# do that, which makes it easy to miss mistakes while editing the configuration.
if ! failures=$( "${GOBIN}/golangci-lint" config verify --config="${golangci_config:-}" 2>&1 ); then
cat >&2 <<EOF
Verification of the golangci-lint configuration failed. Command:
${GOBIN}/golangci-lint config verify --config="${golangci_config:-}")
Result:
$failures
EOF
exit 1
fi
if [ "${golangci_config}" ]; then
# The relative path to _output/local/bin only works if that actually is the
# GOBIN. If not, then we have to make a temporary copy of the config and