golangci-lint: add hints for error wrapping

Wrapping errors may or may not be the right thing to do (see
https://go.dev/blog/go1.13-errors#whether-to-wrap and the discussion in
https://github.com/kubernetes/kubernetes/issues/123234). But developers should
at least think about it, so let's emit linter hints for it: the golangci-lint
config by default enables it for go-errorlint, just not the linter itself, so
we just need to add it for the "hints" config.

Direct error comparisons and assertions also get checked. Those are typically
something that should be replaced by errors.Is and errors.As, but as the
existing code often doesn't do that, let's also treat those as just hints.
This commit is contained in:
Patrick Ohly 2024-02-13 14:12:04 +01:00
parent 5909bd2ddf
commit 8876b68a60
2 changed files with 4 additions and 0 deletions

View File

@ -84,6 +84,7 @@ linters:
- ginkgolinter
- gocritic
- govet
- errorlint
- ineffassign
- logcheck
- revive

View File

@ -140,6 +140,9 @@ linters:
- ginkgolinter
- gocritic
- govet
{{- if .Hints}}
- errorlint
{{- end}}
- ineffassign
- logcheck
- revive