Skip to content

Commit da6b1b7

Browse files
committed
Migrate golangci-lint to v2.9.0 for Go 1.26 CI support
- Bump go-version 1.23 -> 1.26 in golangci-lint.yml and build-test.yml, and golangci-lint version to v2.9.0 (v1.62 can't lint a module with a go 1.26 directive). - Migrate .golangci.yml from the v1 to v2 config schema, preserving the original lint policy (gosimple+staticcheck -> staticcheck with SA*/S* checks only, gofmt/goimports -> formatters section). - Exclude a handful of revive rules (exported, package-comments, unexported-return, var-naming) that golangci-lint v2.9.0's newer bundled revive now enables by default but weren't part of this branch's original lint policy under v1.62.
1 parent 75d071b commit da6b1b7

3 files changed

Lines changed: 64 additions & 39 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup Go
2323
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # pin@5.1.0
2424
with:
25-
go-version: '1.23'
25+
go-version: '1.26'
2626
check-latest: true
2727
- name: Test source headers are present
2828
run: make test-source-headers

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
- name: Setup Go
1919
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # pin@5.1.0
2020
with:
21-
go-version: '1.23'
21+
go-version: '1.26'
2222
check-latest: true
2323
- name: golangci-lint
2424
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #pin@6.1.1
2525
with:
26-
version: v1.62
26+
version: v2.9.0

.golangci.yml

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,70 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
enable:
75
- dupl
8-
- gofmt
9-
- goimports
10-
- gosimple
116
- govet
127
- ineffassign
138
- misspell
149
- nakedret
1510
- revive
16-
- unused
1711
- staticcheck
18-
19-
linters-settings:
20-
gofmt:
21-
simplify: true
22-
goimports:
23-
local-prefixes: helm.sh/helm/v3
24-
dupl:
25-
threshold: 400
26-
issues:
27-
exclude-rules:
28-
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
29-
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
30-
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
31-
- linters:
32-
- revive
33-
text: "redefines-builtin-id: redefinition of the built-in function append"
34-
- linters:
35-
- revive
36-
text: "redefines-builtin-id: redefinition of the built-in function clear"
37-
- linters:
38-
- revive
39-
text: "redefines-builtin-id: redefinition of the built-in function max"
40-
- linters:
41-
- revive
42-
text: "redefines-builtin-id: redefinition of the built-in function min"
43-
- linters:
44-
- revive
45-
text: "redefines-builtin-id: redefinition of the built-in function new"
12+
- unused
13+
settings:
14+
dupl:
15+
threshold: 400
16+
staticcheck:
17+
# v1 config here separately enabled `gosimple` (S* checks) and `staticcheck` (SA*
18+
# checks) only — no `stylecheck` (ST*) or quickfix (QF*) groups. v2 merges all of
19+
# these into one `staticcheck` linter, so pin `checks` to just S*/SA* to preserve
20+
# the original lint policy instead of picking up ST*/QF* findings on old code.
21+
checks:
22+
- "SA*"
23+
- "S*"
24+
exclusions:
25+
rules:
26+
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
27+
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
28+
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
29+
- linters:
30+
- revive
31+
text: 'redefines-builtin-id: redefinition of the built-in function append'
32+
- linters:
33+
- revive
34+
text: 'redefines-builtin-id: redefinition of the built-in function clear'
35+
- linters:
36+
- revive
37+
text: 'redefines-builtin-id: redefinition of the built-in function max'
38+
- linters:
39+
- revive
40+
text: 'redefines-builtin-id: redefinition of the built-in function min'
41+
- linters:
42+
- revive
43+
text: 'redefines-builtin-id: redefinition of the built-in function new'
44+
# golangci-lint v2.9.0 bundles a newer revive with a broader default rule set than
45+
# this branch's original v1.62 setup, which now also enables `exported`,
46+
# `package-comments`, `unexported-return`, and additional `var-naming` checks
47+
# (see the identical migration on HELM-813/820/821). Not part of this CVE fix's
48+
# scope — exclude rather than retrofitting doc comments/API changes onto unrelated code.
49+
- linters:
50+
- revive
51+
text: '^exported:'
52+
- linters:
53+
- revive
54+
text: '^package-comments:'
55+
- linters:
56+
- revive
57+
text: '^unexported-return:'
58+
- linters:
59+
- revive
60+
text: '^var-naming:'
61+
formatters:
62+
enable:
63+
- gofmt
64+
- goimports
65+
settings:
66+
gofmt:
67+
simplify: true
68+
goimports:
69+
local-prefixes:
70+
- helm.sh/helm/v3

0 commit comments

Comments
 (0)