diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 6f9b4b3cf4..797e71d4f2 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -10,7 +10,7 @@ jobs: go-version: '^1.23' - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: version: latest only-new-issues: true diff --git a/.golangci.yaml b/.golangci.yaml index 3618ff73b3..1d6c55067b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,90 +1,119 @@ -# https://golangci-lint.run/usage/configuration/ - +version: "2" +run: + build-tags: + - envtest linters: - disable: - - contextcheck - - gci - - gofumpt - - goimports enable: + - asasalint + - asciicheck + - bidichk + - bodyclose - depguard + - durationcheck + - errchkjson + - errorlint + - exhaustive + - gocheckcompilerdirectives + - gochecksumtype - gomodguard - - gosimple + - gosec + - gosmopolitan - importas + - loggercheck + - makezero - misspell + - musttag + - nilerr + - nilnesserr + - noctx + - protogetter + - reassign + - recvcheck + - rowserrcheck + - spancheck + - sqlclosecheck + - testifylint - unconvert - presets: - - bugs - - format - - unused - -linters-settings: - gci: - sections: - - standard - - default - - prefix(github.com/percona) - - depguard: + - unparam + - zerologlint + disable: + - contextcheck + settings: + depguard: + rules: + everything: + deny: + - pkg: io/ioutil + desc: | + Use the "io" and "os" packages instead. See https://go.dev/doc/go1.16#ioutil + not-tests: + files: + - '!$test' + deny: + - pkg: net/http/httptest + desc: Should be used only in tests. + - pkg: testing/* + desc: The "testing" packages should be used only in tests. + - pkg: github.com/percona/percona-postgresql-operator/internal/testing/* + desc: The "internal/testing" packages should be used only in tests. + tests: + files: + - $test + deny: + - pkg: github.com/pkg/errors + desc: Use the "errors" package unless you are interacting with stack traces. + errchkjson: + check-error-free-encoding: true + exhaustive: + default-signifies-exhaustive: true + gomodguard: + blocked: + modules: + - gopkg.in/yaml.v2: + recommendations: + - sigs.k8s.io/yaml + - gopkg.in/yaml.v3: + recommendations: + - sigs.k8s.io/yaml + - gotest.tools: + recommendations: + - gotest.tools/v3 + - k8s.io/kubernetes: + reason: | + k8s.io/kubernetes is for managing dependencies of the Kubernetes project, i.e. building kubelet and kubeadm. + importas: + alias: + - pkg: k8s.io/api/(\w+)/(v[\w\w]+) + alias: $1$2 + - pkg: k8s.io/apimachinery/pkg/apis/(\w+)/(v[\w\d]+) + alias: $1$2 + no-unaliased: true + exclusions: + presets: + - comments + - common-false-positives + - legacy + - std-error-handling rules: - everything: - deny: - - pkg: io/ioutil - desc: > - Use the "io" and "os" packages instead. - See https://go.dev/doc/go1.16#ioutil - - not-tests: - files: ['!$test'] - deny: - - pkg: net/http/httptest - desc: Should be used only in tests. - - - pkg: testing/* - desc: The "testing" packages should be used only in tests. - - - pkg: github.com/percona/percona-postgresql-operator/internal/testing/* - desc: The "internal/testing" packages should be used only in tests. - - tests: - files: ['$test'] - deny: - - pkg: github.com/pkg/errors - desc: Use the "errors" package unless you are interacting with stack traces. - - errchkjson: - check-error-free-encoding: true - - exhaustive: - default-signifies-exhaustive: true - - gomodguard: - blocked: - modules: - - gopkg.in/yaml.v2: { recommendations: [sigs.k8s.io/yaml] } - - gopkg.in/yaml.v3: { recommendations: [sigs.k8s.io/yaml] } - - gotest.tools: { recommendations: [gotest.tools/v3] } - - k8s.io/kubernetes: - reason: > - k8s.io/kubernetes is for managing dependencies of the Kubernetes - project, i.e. building kubelet and kubeadm. - - importas: - alias: - - pkg: k8s.io/api/(\w+)/(v[\w\w]+) - alias: $1$2 - - pkg: k8s.io/apimachinery/pkg/apis/(\w+)/(v[\w\d]+) - alias: $1$2 - no-unaliased: true - -run: - build-tags: - - envtest -issues: - exclude-generated: strict - exclude-rules: - # These value types have unmarshal methods. - # https://github.com/raeperd/recvcheck/issues/7 - - linters: [recvcheck] - path: internal/pki/pki.go - text: 'methods of "(Certificate|PrivateKey)"' + - linters: + - recvcheck + path: internal/pki/pki.go + text: methods of "(Certificate|PrivateKey)" + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + settings: + gci: + sections: + - standard + - default + - prefix(github.com/percona) + exclusions: + paths: + - third_party$ + - builtin$ + - examples$