
This particualar warning didn't make it into https://github.com/kubernetes/kubernetes/issues/117288. Discussion on Slack concluded that "it's hard to have a universal policy for all functions marked deprecated" and thus this can only be a hint which must be considered on a case-by-case basis. For example, APIs like sets.String are very unlikely to ever go away, therefore it is entirely up to developers whether they switch to sets.Set even though sets.String is marked as deprecated. Ideally, the deprecation message should explain this. It doesn't for sets ("use generic Set instead"), so a better message in that case would have been "consider using generic Set instead".
168 lines
5.8 KiB
YAML
168 lines
5.8 KiB
YAML
# golangci-lint is used in Kubernetes with different configurations that
|
||
# enable an increasing amount of checks:
|
||
# - golangci.yaml is the most permissive configuration. All existing code
|
||
# passed.
|
||
# - golangci-strict.yaml adds checks that all new code in pull requests
|
||
# must pass.
|
||
# - golangci-hints.yaml adds checks for code patterns where developer
|
||
# and reviewer may decide whether findings should get addressed before
|
||
# merging. Beware that the golangci-lint output includes also the
|
||
# issues that must be fixed and doesn't indicate how severe each issue
|
||
# is (https://gophers.slack.com/archives/CS0TBRKPC/p1685721815275349).
|
||
#
|
||
# All three flavors are generated from golangci.yaml.in with
|
||
# hack/update-golangci-lint-config.sh.
|
||
|
||
run:
|
||
timeout: 30m
|
||
skip-files:
|
||
- "^zz_generated.*"
|
||
|
||
output:
|
||
sort-results: true
|
||
|
||
issues:
|
||
max-issues-per-linter: 0
|
||
max-same-issues: 0
|
||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||
exclude-rules:
|
||
# exclude ineffassign linter for generated files for conversion
|
||
- path: conversion\.go
|
||
linters:
|
||
- ineffassign
|
||
|
||
# SSA Extract calls are allowed in tests.
|
||
- linters:
|
||
- forbidigo
|
||
text: should not be used because managedFields was removed
|
||
path: _test.go$
|
||
|
||
{{- if .Base}}
|
||
|
||
# TODO(oscr) 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/*)
|
||
linters:
|
||
- gocritic
|
||
{{- end}}
|
||
|
||
# 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:
|
||
- stylecheck
|
||
text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)"
|
||
|
||
# This check currently has some false positives (https://github.com/nunnatsa/ginkgolinter/issues/91).
|
||
- linters:
|
||
- ginkgolinter
|
||
text: use a function call in (Eventually|Consistently)
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507012435
|
||
- linters:
|
||
- gocritic
|
||
text: "ifElseChain: rewrite if-else to switch statement"
|
||
|
||
{{- if not .Hints}}
|
||
|
||
# The following issues were deemed "might be worth fixing, needs to be
|
||
# decided on a case-by-case basis". This was initially decided by a
|
||
# majority of the developers who voted in
|
||
# https://github.com/kubernetes/kubernetes/issues/117288 and may evolve
|
||
# over time.
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008918
|
||
- linters:
|
||
- gocritic
|
||
text: "assignOp:"
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507016854
|
||
- linters:
|
||
- gosimple
|
||
text: "S1002: should omit comparison to bool constant"
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507023980
|
||
- linters:
|
||
- gosimple
|
||
text: "S1016: should convert opts .* instead of using struct literal"
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507026758
|
||
- linters:
|
||
- gosimple
|
||
text: "S1033: unnecessary guard around call to delete"
|
||
|
||
# Didn't make it into https://github.com/kubernetes/kubernetes/issues/117288.
|
||
# Discussion on Slack concluded that "it's hard to have a universal policy for all
|
||
# functions marked deprecated" and thus this can only be a hint which must
|
||
# be considered on a case-by-case basis.
|
||
- linters:
|
||
- staticcheck
|
||
text: "SA1019: .*is deprecated"
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507030071
|
||
- linters:
|
||
- stylecheck
|
||
text: "ST1012: error var .* should have name of the form ErrFoo"
|
||
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507031224
|
||
- linters:
|
||
- stylecheck
|
||
text: "ST1023: should omit type .* from declaration; it will be inferred from the right-hand side"
|
||
{{- end}}
|
||
|
||
linters:
|
||
disable-all: {{if .Base -}} true {{- else -}} false {{- end}}
|
||
enable: # please keep this alphabetized
|
||
- forbidigo
|
||
- ginkgolinter
|
||
- gocritic
|
||
- govet
|
||
- ineffassign
|
||
- logcheck
|
||
- staticcheck
|
||
- stylecheck
|
||
- unused
|
||
{{- if .Strict}}
|
||
disable:
|
||
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008359
|
||
- errcheck
|
||
{{- end}}
|
||
|
||
linters-settings: # please keep this alphabetized
|
||
custom:
|
||
logcheck:
|
||
# Installed there by hack/verify-golangci-lint.sh.
|
||
path: ../_output/local/bin/logcheck.so
|
||
description: structured logging checker
|
||
original-url: k8s.io/logtools/logcheck
|
||
forbidigo:
|
||
analyze-types: true
|
||
forbid:
|
||
- p: ^managedfields\.ExtractInto$
|
||
pkg: ^k8s\.io/apimachinery/pkg/util/managedfields$
|
||
msg: should not be used because managedFields was removed
|
||
- p: \.Extract
|
||
pkg: ^k8s\.io/client-go/applyconfigurations/
|
||
msg: should not be used because managedFields was removed
|
||
{{- if .Base }}
|
||
gocritic:
|
||
enabled-checks:
|
||
- equalFold
|
||
- boolExprSimplify
|
||
{{- end}}
|
||
staticcheck:
|
||
checks:
|
||
- "all"
|
||
{{- if .Base }}
|
||
- "-SA1019" # TODO(fix) Using a deprecated function, variable, constant or field
|
||
- "-SA2002" # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
|
||
{{- end}}
|
||
{{- if .Base }}
|
||
stylecheck:
|
||
checks:
|
||
- "ST1019" # Importing the same package multiple times
|
||
{{- end}}
|