update golangci-lint to v2.1.6

This commit is contained in:
CrazyMax
2025-08-03 20:18:35 +02:00
parent e7cfeb4eb1
commit 8aaf66da27
2 changed files with 97 additions and 78 deletions

View File

@@ -1,12 +1,11 @@
version: "2"
run: run:
timeout: 30m modules-download-mode: vendor
build-tags: build-tags:
- containers_image_openpgp - containers_image_openpgp
- exclude_graphdriver_btrfs - exclude_graphdriver_btrfs
- exclude_graphdriver_devicemapper - exclude_graphdriver_devicemapper
# default uses Go version from the go.mod file, fallback on the env var
# `GOVERSION`, fallback on 1.17: https://golangci-lint.run/usage/configuration/#run-configuration
go: "1.23"
linters: linters:
enable: enable:
@@ -14,10 +13,7 @@ linters:
- depguard - depguard
- forbidigo - forbidigo
- gocritic - gocritic
- gofmt
- goimports
- gosec - gosec
- gosimple
- govet - govet
- ineffassign - ineffassign
- makezero - makezero
@@ -27,79 +23,102 @@ linters:
- revive - revive
- staticcheck - staticcheck
- testifylint - testifylint
- typecheck
- unused - unused
- whitespace - whitespace
disable-all: true settings:
gocritic:
linters-settings: disabled-checks:
gocritic: - "ifElseChain"
disabled-checks: - "assignOp"
- "ifElseChain" - "appendAssign"
- "assignOp" - "singleCaseSwitch"
- "appendAssign" importas:
- "singleCaseSwitch" alias:
- "exitAfterDefer" # FIXME - pkg: "github.com/opencontainers/image-spec/specs-go/v1"
importas: alias: "ocispecs"
alias: - pkg: "github.com/opencontainers/go-digest"
- pkg: "github.com/opencontainers/image-spec/specs-go/v1" alias: "digest"
alias: "ocispecs" govet:
- pkg: "github.com/opencontainers/go-digest" enable:
alias: "digest" - nilness
govet: - unusedwrite
enable: depguard:
- nilness rules:
- unusedwrite main:
depguard: deny:
- pkg: "github.com/containerd/containerd/errdefs"
desc: The containerd errdefs package was migrated to a separate module. Use github.com/containerd/errdefs instead.
- pkg: "github.com/containerd/containerd/log"
desc: The containerd log package was migrated to a separate module. Use github.com/containerd/log instead.
- pkg: "github.com/containerd/containerd/platforms"
desc: The containerd platforms package was migrated to a separate module. Use github.com/containerd/platforms instead.
- pkg: "io/ioutil"
desc: The io/ioutil package has been deprecated.
forbidigo:
forbid:
- pattern: ^context\.WithCancel(# use context\.WithCancelCause instead)?$
- pattern: ^context\.WithDeadline(# use context\.WithDeadline instead)?$
- pattern: ^context\.WithTimeout(# use context\.WithTimeoutCause instead)?$
- pattern: ^ctx\.Err(# use context\.Cause instead)?$
- pattern: ^fmt\.Errorf(# use errors\.Errorf instead)?$
- pattern: ^platforms\.DefaultString(# use platforms\.Format(platforms\.DefaultSpec()) instead\.)?$
gosec:
excludes:
- G204
- G402
- G115
config:
G306: "0644"
testifylint:
disable:
- "empty"
- "bool-compare"
- "len"
- "negative-positive"
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules: rules:
main: -
deny: linters:
- pkg: "github.com/containerd/containerd/platforms" - revive
desc: The containerd platforms package was migrated to a separate module. Use github.com/containerd/platforms instead. text: stutters
- pkg: "io/ioutil" -
desc: The io/ioutil package has been deprecated. linters:
forbidigo: - revive
forbid: text: empty-block
- '^fmt\.Errorf(# use errors\.Errorf instead)?$' -
- '^platforms\.DefaultString(# use platforms\.Format(platforms\.DefaultSpec()) instead\.)?$' linters:
gosec: - revive
excludes: text: superfluous-else
- G204 # Audit use of command execution -
- G402 # TLS MinVersion too low linters:
- G115 # integer overflow conversion - revive
config: text: unused-parameter
G306: "0644" -
testifylint: linters:
disable: - revive
# disable rules that reduce the test condition text: redefines-builtin-id
- "empty" -
- "bool-compare" linters:
- "len" - revive
- "negative-positive" text: if-return
paths:
- .*\.pb\.go$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- .*\.pb\.go$
issues: issues:
exclude-files:
- ".*\\.pb\\.go$"
exclude-rules:
- linters:
- revive
text: "stutters"
- linters:
- revive
text: "empty-block"
- linters:
- revive
text: "superfluous-else"
- linters:
- revive
text: "unused-parameter"
- linters:
- revive
text: "redefines-builtin-id"
- linters:
- revive
text: "if-return"
# show all
max-issues-per-linter: 0 max-issues-per-linter: 0
max-same-issues: 0 max-same-issues: 0

View File

@@ -3,8 +3,8 @@
ARG GO_VERSION="1.23" ARG GO_VERSION="1.23"
ARG XX_VERSION="1.6.1" ARG XX_VERSION="1.6.1"
ARG ALPINE_VERSION="3.21" ARG ALPINE_VERSION="3.21"
ARG GOLANGCI_LINT_VERSION="v1.62.2" ARG GOLANGCI_LINT_VERSION="v2.1.6"
ARG GOLANGCI_FROM_SOURCE="false" ARG GOLANGCI_FROM_SOURCE="true"
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx