Skip to content

Commit 8d9766c

Browse files
committed
ci: switch to golangci-lint v2.0
The new configuration files were initially generated by `golangci-lint migrate`, when tweaked to minimize and simplify. golangci-lint v2 switches to a new version of staticcheck which shows much more warnings. Some of them were fixed by a few previous commits, and the rest of them are disabled. Also, golangci-extra was modified to include ALL staticcheck linters. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 5086883 commit 8d9766c

File tree

3 files changed

+48
-35
lines changed

3 files changed

+48
-35
lines changed

.github/workflows/validate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
permissions: read-all
1212

1313
env:
14-
LINT_VERSION: v1.64.8
14+
LINT_VERSION: v2.0
1515

1616
jobs:
1717
codespell:
@@ -37,13 +37,13 @@ jobs:
3737
sudo apt-get -qq update
3838
sudo apt-get -qq install libseccomp-dev
3939
- name: lint
40-
uses: golangci/golangci-lint-action@v6
40+
uses: golangci/golangci-lint-action@v7
4141
with:
4242
version: "${{ env.LINT_VERSION }}"
4343
args: --verbose
4444
# Extra linters, only checking new code from a pull request.
4545
- name: lint-extra
46-
uses: golangci/golangci-lint-action@v6
46+
uses: golangci/golangci-lint-action@v7
4747
with:
4848
args: --config=.golangci-extra.yml
4949
version: "${{ env.LINT_VERSION }}"

.golangci-extra.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
# The idea is to impose additional rules for newly added code only
77
# (rules we can not realistically satisfy for existing code).
88

9+
version: "2"
10+
911
run:
12+
timeout: 5m
1013
build-tags:
1114
- apparmor
1215
- seccomp
1316
- selinux
1417
- systemd
1518
- exclude_graphdriver_btrfs
1619
- containers_image_openpgp
17-
timeout: 5m
1820

1921
linters:
20-
disable-all: true
22+
default: none
2123
enable:
2224
- godot
25+
- staticcheck
26+
settings:
27+
staticcheck:
28+
checks:
29+
- all

.golangci.yml

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
---
1+
version: "2"
2+
23
run:
4+
timeout: 5m
35
build-tags:
46
- apparmor
57
- seccomp
@@ -8,7 +10,11 @@ run:
810
- exclude_graphdriver_btrfs
911
- containers_image_openpgp
1012
- cni
11-
timeout: 5m
13+
14+
formatters:
15+
enable:
16+
- gofumpt
17+
1218
linters:
1319
enable:
1420
- asasalint
@@ -30,7 +36,6 @@ linters:
3036
- gocheckcompilerdirectives
3137
- gochecksumtype
3238
- gocritic
33-
- gofumpt
3439
- goprintffuncname
3540
- gosmopolitan
3641
- iface
@@ -53,31 +58,32 @@ linters:
5358
- usetesting
5459
- wastedassign
5560
- whitespace
56-
57-
linters-settings:
58-
errcheck:
59-
check-type-assertions: true
60-
gocyclo:
61-
min-complexity: 35
62-
gofmt:
63-
rewrite-rules:
64-
- pattern: 'interface{}'
65-
replacement: 'any'
66-
revive:
61+
settings:
62+
errcheck:
63+
check-type-assertions: true
64+
gocyclo:
65+
min-complexity: 35
66+
revive:
67+
rules:
68+
- name: dot-imports
69+
disabled: true
70+
staticcheck:
71+
checks:
72+
- all
73+
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
74+
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
75+
exclusions:
76+
generated: strict
77+
presets:
78+
- comments
79+
- common-false-positives
80+
- std-error-handling
6781
rules:
68-
- name: dot-imports
69-
disabled: true
70-
71-
issues:
72-
# Excluding configuration per-path, per-linter, per-text and per-source
73-
exclude-rules:
74-
# Exclude some linters from running on tests files.
75-
- path: _test\.go
76-
linters:
77-
- dupl
78-
- perfsprint
79-
# Exclude "should pass the context parameter" for libimage.LookupImage because of backward compatibility.
80-
- path: "libimage"
81-
text: "LookupImage"
82-
linters:
83-
- contextcheck
82+
- linters:
83+
- dupl
84+
- perfsprint
85+
path: _test\.go
86+
- linters:
87+
- contextcheck
88+
path: libimage
89+
text: LookupImage

0 commit comments

Comments
 (0)