golangci-lint: don't warn about conversion and defaulting functions

The linter suppression got removed in the migration to golangci-lint v2 because
it wasn't triggered for existing code, but as seen in a PR which adds a
conversion package the suppression is still needed.

Furthermore, we also want to suppress for unexported, manually written
conversion and defaulting functions because those follow the same Kubernetes
naming convention.
This commit is contained in:
Patrick Ohly
2025-05-05 12:57:13 +02:00
parent 15d9a93d7c
commit 2ea4b1aba6
3 changed files with 33 additions and 0 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$