diff --git a/common/.github/workflows/validate.yml b/common/.github/workflows/validate.yml index 14eb0ce22f..28b2413c1d 100644 --- a/common/.github/workflows/validate.yml +++ b/common/.github/workflows/validate.yml @@ -11,7 +11,7 @@ on: permissions: read-all env: - LINT_VERSION: v1.64.8 + LINT_VERSION: v2.0 jobs: codespell: @@ -37,13 +37,13 @@ jobs: sudo apt-get -qq update sudo apt-get -qq install libseccomp-dev - name: lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: version: "${{ env.LINT_VERSION }}" args: --verbose # Extra linters, only checking new code from a pull request. - name: lint-extra - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: args: --config=.golangci-extra.yml version: "${{ env.LINT_VERSION }}" diff --git a/common/.golangci-extra.yml b/common/.golangci-extra.yml index 849b7fcb44..f77d1811f6 100644 --- a/common/.golangci-extra.yml +++ b/common/.golangci-extra.yml @@ -6,7 +6,10 @@ # The idea is to impose additional rules for newly added code only # (rules we can not realistically satisfy for existing code). +version: "2" + run: + timeout: 5m build-tags: - apparmor - seccomp @@ -14,9 +17,13 @@ run: - systemd - exclude_graphdriver_btrfs - containers_image_openpgp - timeout: 5m linters: - disable-all: true + default: none enable: - godot + - staticcheck + settings: + staticcheck: + checks: + - all diff --git a/common/.golangci.yml b/common/.golangci.yml index 68c3b12be8..c5e98a9909 100644 --- a/common/.golangci.yml +++ b/common/.golangci.yml @@ -1,5 +1,7 @@ ---- +version: "2" + run: + timeout: 5m build-tags: - apparmor - seccomp @@ -8,7 +10,11 @@ run: - exclude_graphdriver_btrfs - containers_image_openpgp - cni - timeout: 5m + +formatters: + enable: + - gofumpt + linters: enable: - asasalint @@ -30,7 +36,6 @@ linters: - gocheckcompilerdirectives - gochecksumtype - gocritic - - gofumpt - goprintffuncname - gosmopolitan - iface @@ -53,31 +58,32 @@ linters: - usetesting - wastedassign - whitespace - -linters-settings: - errcheck: - check-type-assertions: true - gocyclo: - min-complexity: 35 - gofmt: - rewrite-rules: - - pattern: 'interface{}' - replacement: 'any' - revive: + settings: + errcheck: + check-type-assertions: true + gocyclo: + min-complexity: 35 + revive: + rules: + - name: dot-imports + disabled: true + staticcheck: + checks: + - all + - -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier. + - -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression. + exclusions: + generated: strict + presets: + - comments + - common-false-positives + - std-error-handling rules: - - name: dot-imports - disabled: true - -issues: - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - dupl - - perfsprint - # Exclude "should pass the context parameter" for libimage.LookupImage because of backward compatibility. - - path: "libimage" - text: "LookupImage" - linters: - - contextcheck + - linters: + - dupl + - perfsprint + path: _test\.go + - linters: + - contextcheck + path: libimage + text: LookupImage