Skip to content

Commit 13b9455

Browse files
Merge pull request #402 from kate-goldenring/golangci-lint-v2
chore: migrate to golangci-lint v2
2 parents e0708b3 + 83dccc8 commit 13b9455

File tree

3 files changed

+89
-83
lines changed

3 files changed

+89
-83
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ jobs:
7777
go-version: '1.23.x'
7878
- uses: actions/checkout@v4
7979
- name: golangci-lint
80-
uses: golangci/golangci-lint-action@v6
80+
uses: golangci/golangci-lint-action@v8
8181
with:
82-
version: v1.60.1
82+
version: v2.1.6
8383
args: --timeout=10m
8484

8585
lint_shell:

.golangci.yaml

Lines changed: 86 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,105 @@
1-
issues:
2-
# The default exclude list seems rather aggressive, opt-in when needed instead
3-
exclude-use-default: false
4-
5-
exclude-rules:
6-
# Duplicated errcheck checks
7-
- linters: [gosec]
8-
text: G104
9-
# Duplicated errcheck checks
10-
- linters: [staticcheck]
11-
text: SA5001
12-
# We don't require comments on everything
13-
- linters: [golint]
14-
text: should have( a package)? comment
15-
# very long lines are ok if they're URLs
16-
- linters: [lll]
17-
source: https?://
18-
# very long lines are ok if they're go:generate
19-
- linters: [lll]
20-
source: "^//go:generate "
21-
# Ignore errcheck on deferred Close
22-
- linters: [errcheck]
23-
source: ^\s*defer .*\.Close(.*)$
24-
# Ignore ineffective assignments to ctx
25-
- linters: [ineffassign]
26-
source: ^\s*ctx.*=.*$
27-
- linters: [staticcheck]
28-
source: ^\s*ctx.*=.*$
29-
# Don't require package docs
30-
- linters: [stylecheck]
31-
text: ST1000
32-
# Unparam is allowed in tests
33-
- linters: [unparam]
34-
path: _test\.go
35-
1+
version: "2"
362
linters:
37-
disable-all: true
3+
default: none
384
enable:
395
- bodyclose
406
- depguard
417
- errcheck
428
- errorlint
9+
- forbidigo
4310
- goconst
4411
- gocyclo
45-
- gofmt
46-
- goimports
4712
- gosec
48-
- gosimple
4913
- govet
5014
- ineffassign
5115
- lll
5216
- misspell
5317
- nakedret
5418
- staticcheck
55-
- stylecheck
56-
- typecheck
5719
- unconvert
5820
- unparam
5921
- unused
60-
- forbidigo
61-
62-
linters-settings:
63-
govet:
64-
disable:
65-
- shadow
66-
gocyclo:
67-
min-complexity: 15
68-
dupl:
69-
# Don't detect small duplications, but if we're duplicating functions across
70-
# packages, we should consider refactoring.
71-
threshold: 100
72-
depguard:
22+
settings:
23+
depguard:
24+
rules:
25+
main:
26+
files:
27+
- $all
28+
deny:
29+
- pkg: github.com/pkg/errors
30+
desc: 'use Go 1.13 errors instead: https://blog.golang.org/go1.13-errors'
31+
testing:
32+
files:
33+
- $test
34+
deny:
35+
- pkg: github.com/stretchr/testify/assert
36+
desc: use github.com/stretchr/testify/require instead
37+
dupl:
38+
threshold: 100
39+
forbidigo:
40+
forbid:
41+
- pattern: ^print.*$
42+
- pattern: ^fmt\.Print.*$
43+
msg: Do not commit print statements.
44+
- pattern: ^os\.Getenv
45+
msg: Pull values through configuration rather than os.Getenv
46+
goconst:
47+
min-len: 8
48+
min-occurrences: 10
49+
gocyclo:
50+
min-complexity: 15
51+
govet:
52+
disable:
53+
- shadow
54+
lll:
55+
line-length: 180
56+
exclusions:
57+
generated: lax
7358
rules:
74-
main:
75-
files:
76-
- '$all'
77-
deny:
78-
- pkg: "github.com/pkg/errors"
79-
desc: "use Go 1.13 errors instead: https://blog.golang.org/go1.13-errors"
80-
testing:
81-
files: ['$test']
82-
deny:
83-
- pkg: "github.com/stretchr/testify/assert"
84-
desc: "use github.com/stretchr/testify/require instead"
85-
goconst:
86-
min-len: 8
87-
min-occurrences: 10
88-
lll:
89-
line-length: 180
90-
forbidigo:
91-
# Forbid the following identifiers (list of regexp).
92-
# Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
93-
forbid:
94-
# Builtin function:
95-
- ^print.*$
96-
- p: ^fmt\.Print.*$
97-
msg: Do not commit print statements.
98-
- p: ^os\.Getenv
99-
msg: Pull values through configuration rather than os.Getenv
59+
- linters:
60+
- gosec
61+
text: G104
62+
- linters:
63+
- staticcheck
64+
text: SA5001
65+
- linters:
66+
- staticcheck
67+
text: QF1008
68+
- linters:
69+
- golint
70+
text: should have( a package)? comment
71+
- linters:
72+
- lll
73+
source: https?://
74+
- linters:
75+
- lll
76+
source: '^//go:generate '
77+
- linters:
78+
- errcheck
79+
source: ^\s*defer .*\.Close(.*)$
80+
- linters:
81+
- ineffassign
82+
source: ^\s*ctx.*=.*$
83+
- linters:
84+
- staticcheck
85+
source: ^\s*ctx.*=.*$
86+
- linters:
87+
- staticcheck
88+
text: ST1000
89+
- linters:
90+
- unparam
91+
path: _test\.go
92+
paths:
93+
- third_party$
94+
- builtin$
95+
- examples$
96+
formatters:
97+
enable:
98+
- gofmt
99+
- goimports
100+
exclusions:
101+
generated: lax
102+
paths:
103+
- third_party$
104+
- builtin$
105+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test: manifests generate fmt vet envtest ## Run tests.
7575
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race $(shell go list ./... | grep -v e2e) -coverprofile cover.out
7676

7777
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
78-
GOLANGCI_LINT_VERSION ?= v1.54.2
78+
GOLANGCI_LINT_VERSION ?= v2.1.6
7979
golangci-lint:
8080
@[ -f $(GOLANGCI_LINT) ] || { \
8181
set -e ;\

0 commit comments

Comments
 (0)