From 86acb468d8ca7dda3fb625ec97e1f4c8edb3c609 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Fri, 11 Apr 2025 16:36:59 -0400 Subject: [PATCH] bump to golangci yaml v2 --- .golangci.yaml | 160 ++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 6e97f103c..4a9485d7a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,66 +1,15 @@ +version: "2" run: - timeout: 10m + build-tags: + - e2e + - hpa + - upgrade allow-parallel-runners: true - exclude-dirs: - - client - - injection/clients - output: - sort-results: true sort-order: - - linter - - file - show-stats: true - - -issues: - uniq-by-line: true - max-issues-per-linter: 0 - max-same-issues: 0 - exclude-rules: - - path: test # Excludes /test, *_test.go etc. - linters: - - gosec - - unparam - - noctx - - protogetter - - linters: ["gocritic"] - # Fixes are non-trivial do in a follow up - text: "ifElseChain" - -linters-settings: - # goimports: - # local-prefixes: knative.dev/pkg - gomodguard: - blocked: - modules: - - github.com/ghodss/yaml: - recommendations: - - sigs.k8s.io/yaml - - go.uber.org/atomic: - recommendations: - - sync/atomic - - io/ioutil: - recommendations: - - os - - io - - github.com/hashicorp/go-multierror: - reason: "use errors.Join" - recommendations: - - errors - - go.uber.org/multierr: - reason: "use errors.Join" - recommendations: - - errors - revive: - rules: - # use unparam linter instead - defaults are better - - name: unused-parameter - disabled: true - + - linter + - file linters: - disable: - - errcheck enable: # Check for pass []any as any in variadic func(...any). - asasalint @@ -81,7 +30,7 @@ linters: # # Containedctx is a linter that detects struct contained context.Context # # field. # - containedctx - + # # TODO - do a follow up PR # # Check whether the function uses a non-inherited context. # - contextcheck @@ -115,27 +64,12 @@ linters: # report message and optional suggestion. - gocritic - # Gofmt checks whether code was gofmt-ed. By default this tool runs - # with -s option to check for code simplification. - - gofmt - - # Gofumpt checks whether code was gofumpt-ed. - - gofumpt - - # Check import statements are formatted according to the 'goimport' - # command. Reformat imports in autofix mode. - - goimports - # See config below - gomodguard # Inspects source code for security problems. - gosec - # Linter that specializes in simplifying code. - - gosimple - - govet - # Intrange is a linter to find places where for loops could make use of # an integer range. - intrange @@ -183,12 +117,7 @@ linters: # Checks for mistakes with OpenTelemetry/Census spans. - spancheck - # Stylecheck is a replacement for golint. - - stylecheck - - # Tenv is analyzer that detects using os.Setenv instead of t.Setenv - # since Go1.17. - - tenv + - staticcheck # Linter checks if examples are testable (have an expected output). - testableexamples @@ -209,4 +138,73 @@ linters: # Whitespace is a linter that checks for unnecessary newlines at the start # and end of functions, if, for, etc. - whitespace - + disable: + - errcheck + settings: + gocritic: + disabled-checks: + - exitAfterDefer + - appendAssign + gomodguard: + blocked: + modules: + - github.com/ghodss/yaml: + recommendations: + - sigs.k8s.io/yaml + - go.uber.org/atomic: + recommendations: + - sync/atomic + - io/ioutil: + recommendations: + - os + - io + - github.com/hashicorp/go-multierror: + recommendations: + - errors + reason: use errors.Join + - go.uber.org/multierr: + recommendations: + - errors + reason: use errors.Join + revive: + rules: + - name: unused-parameter + disabled: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - gosec + - noctx + - protogetter + - unparam + path: test + - linters: + - gocritic + text: ifElseChain + paths: + - pkg/client + - third_party$ + - builtin$ + - examples$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + uniq-by-line: true +formatters: + enable: + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - pkg/client + - third_party$ + - builtin$ + - examples$