From e0cca373dd4080201d39da5febb864851917a7ad Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Thu, 5 Sep 2024 16:50:41 +0200 Subject: [PATCH] golangci: add comments to enabled linters also fixes some deprecations --- .golangci.yml | 102 +++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b1cace11e6e8..513c7c88c8d1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,62 +4,55 @@ run: build-tags: - tools - e2e - skip-files: - - "zz_generated.*\\.go$" - - "vendored_openapi\\.go$" - # We don't want to invest time to fix new linter findings in old API types. - - "internal/apis/.*" allow-parallel-runners: true linters: disable-all: true enable: - - asasalint - - asciicheck - - bidichk - - bodyclose - - containedctx - - copyloopvar - - dogsled - - dupword - - durationcheck - - errcheck - - errchkjson - - gci - - ginkgolinter - - goconst - - gocritic - - godot - - gofmt - - goimports - - goprintffuncname - - gosec - - gosimple - - govet - - importas - - ineffassign - - intrange - - loggercheck - - misspell - - nakedret - - nilerr - - noctx - - nolintlint - - nosprintfhostport - - prealloc - - predeclared - - revive - - rowserrcheck - - staticcheck - - stylecheck - - tenv - - thelper - - typecheck - - unconvert - - unparam - - unused - - usestdlibvars - - whitespace + - asasalint # warns about passing []any to func(...any) without expanding it + - asciicheck # non ascii symbols + - bidichk # dangerous unicode sequences + - bodyclose # unclosed http bodies + - containedctx # context.Context nested in a struct + - copyloopvar # copying loop variables + - dogsled # too many blank identifiers in assignments + - dupword # duplicate words + - durationcheck # multiplying two durations + - errcheck # unchecked errors + - errchkjson # invalid types passed to json encoder + - gci # ensures imports are organized + - ginkgolinter # ginkgo and gomega + - goconst # strings that can be replaced by constants + - gocritic # bugs, performance, style (we could add custom ones to this one) + - godot # checks that comments end in a period + - gofmt # warns about incorrect use of fmt functions + - goimports # import formatting + - goprintffuncname # printft-like functions should be named with f at the end + - gosec # potential security problems + - gosimple # simplify code + - govet # basically 'go vet' + - importas # consistent import aliases + - ineffassign # ineffectual assignments + - intrange # suggest using integer range in for loops + - loggercheck # check for even key/value pairs in logger calls + - misspell # spelling + - nakedret # naked returns (named return parameters and an empty return) + - nilerr # returning nil after checking err is not nil + - noctx # http requests without context.Context + - nolintlint # badly formatted nolint directives + - nosprintfhostport # using sprintf to construct host:port in a URL + - prealloc # suggest preallocating slices + - predeclared # shadowing predeclared identifiers + - revive # better version of golint + - staticcheck # some of staticcheck's rules + - stylecheck # another replacement for golint + - tenv # using os.Setenv instead of t.Setenv in tests + - thelper # test helpers not starting with t.Helper() + - unconvert # unnecessary type conversions + - unparam # unused function parameters + - unused # unused constants, variables,functions, types + - usestdlibvars # using variables/constants from the standard library + - whitespace # unnecessary newlines linters-settings: gci: @@ -187,7 +180,6 @@ linters-settings: alias: infraexpv1 nolintlint: allow-unused: false - allow-leading-space: false require-specific: true revive: rules: @@ -224,6 +216,12 @@ linters-settings: goconst: ignore-tests: true issues: + exclude-files: + - "zz_generated.*\\.go$" + - "vendored_openapi\\.go$" + # We don't want to invest time to fix new linter findings in old API types. + - "internal/apis/.*" + max-same-issues: 0 max-issues-per-linter: 0 # We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant