Merge pull request #131606 from pohly/golangci-lint@v2-fixes

golangci-lint: some fixes after migration to v2
This commit is contained in:
Kubernetes Prow Robot
2025-05-07 11:31:17 -07:00
committed by GitHub
4 changed files with 40 additions and 1 deletions

View File

@@ -91,6 +91,17 @@ linters:
text: should not use Add, use AddVersioned instead
path: _test.go$
# The Kubernetes naming convention for conversion functions uses underscores
# and intentionally deviates from normal Go conventions to make those function
# names more readable. Same for SetDefaults_*.
#
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507028627
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
- linters:
- staticcheck
- revive
text: "(ST1003: should not use underscores in Go names; func ([cC]onvert_.*_To_.*|[sS]etDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
- path: (.+)\.go$
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
text: ineffective break statement. Did you mean to break out of the outer loop

View File

@@ -91,6 +91,17 @@ linters:
text: should not use Add, use AddVersioned instead
path: _test.go$
# The Kubernetes naming convention for conversion functions uses underscores
# and intentionally deviates from normal Go conventions to make those function
# names more readable. Same for SetDefaults_*.
#
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507028627
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
- linters:
- staticcheck
- revive
text: "(ST1003: should not use underscores in Go names; func ([cC]onvert_.*_To_.*|[sS]etDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
# TODO(https://github.com/kubernetes/kubernetes/issues/131475): Remove these excluded directories and fix findings. Due to large amount of findings in different components
# with different owners it's hard to fix everything in a single pr. This will therefore be done in multiple prs.
- path: (pkg/volume/*|test/*|azure/*|pkg/cmd/wait*|request/bearertoken/*|metrics/*|filters/*)

View File

@@ -91,6 +91,17 @@ linters:
text: should not use Add, use AddVersioned instead
path: _test.go$
# The Kubernetes naming convention for conversion functions uses underscores
# and intentionally deviates from normal Go conventions to make those function
# names more readable. Same for SetDefaults_*.
#
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507028627
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
- linters:
- staticcheck
- revive
text: "(ST1003: should not use underscores in Go names; func ([cC]onvert_.*_To_.*|[sS]etDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
{{- if .Hints}}
- path: (.+)\.go$

View File

@@ -184,7 +184,13 @@ run () {
# Only output on stderr indicates a real error and gets the "ERROR: " prefix for
# highlighting in Spyglass. Stdout contains statistics and shouldn't get that prefix.
# To avoid interleaving, it gets collected and dumped separately at the end.
"${golangci[@]}" "${targets[@]}" 2> >(sed -e 's;^;ERROR: ;') >"${KUBE_TEMP}/golangci-stdout.log" || res=$?
#
# This is done with some bash magic:
# - save original stdout in FD 3
# - redirect stdout to file
# - redirect stderr to original stdout in FD 3
# - pipe stderr via stdout into sed for on-the-fly processing, writing to stderr again
"${golangci[@]}" "${targets[@]}" 3>&1 >"${KUBE_TEMP}/golangci-stdout.log" 2>&3 | sed -e 's;^;ERROR: ;' >&2 || res=$?
cat "${KUBE_TEMP}/golangci-stdout.log"
}
# First run with normal output.