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,19 +23,15 @@ linters:
- revive - revive
- staticcheck - staticcheck
- testifylint - testifylint
- typecheck
- unused - unused
- whitespace - whitespace
disable-all: true settings:
linters-settings:
gocritic: gocritic:
disabled-checks: disabled-checks:
- "ifElseChain" - "ifElseChain"
- "assignOp" - "assignOp"
- "appendAssign" - "appendAssign"
- "singleCaseSwitch" - "singleCaseSwitch"
- "exitAfterDefer" # FIXME
importas: importas:
alias: alias:
- pkg: "github.com/opencontainers/image-spec/specs-go/v1" - pkg: "github.com/opencontainers/image-spec/specs-go/v1"
@@ -54,52 +46,79 @@ linters-settings:
rules: rules:
main: main:
deny: 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" - pkg: "github.com/containerd/containerd/platforms"
desc: The containerd platforms package was migrated to a separate module. Use github.com/containerd/platforms instead. desc: The containerd platforms package was migrated to a separate module. Use github.com/containerd/platforms instead.
- pkg: "io/ioutil" - pkg: "io/ioutil"
desc: The io/ioutil package has been deprecated. desc: The io/ioutil package has been deprecated.
forbidigo: forbidigo:
forbid: forbid:
- '^fmt\.Errorf(# use errors\.Errorf instead)?$' - pattern: ^context\.WithCancel(# use context\.WithCancelCause instead)?$
- '^platforms\.DefaultString(# use platforms\.Format(platforms\.DefaultSpec()) 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: gosec:
excludes: excludes:
- G204 # Audit use of command execution - G204
- G402 # TLS MinVersion too low - G402
- G115 # integer overflow conversion - G115
config: config:
G306: "0644" G306: "0644"
testifylint: testifylint:
disable: disable:
# disable rules that reduce the test condition
- "empty" - "empty"
- "bool-compare" - "bool-compare"
- "len" - "len"
- "negative-positive" - "negative-positive"
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
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
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