Skip to content

Commit eb8b04b

Browse files
committed
Migrate to golangci-lint v2
Signed-off-by: Tero Saarni <[email protected]>
1 parent a0d8cb2 commit eb8b04b

File tree

3 files changed

+133
-114
lines changed

3 files changed

+133
-114
lines changed

.github/workflows/prbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: golangci-lint
3030
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
3131
with:
32-
version: v1.64.5
32+
version: v2.0.2
3333
args: --build-tags=e2e,conformance,gcp,oidc,none --out-format=colored-line-number
3434
codespell:
3535
name: Codespell

.golangci.yml

Lines changed: 131 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,137 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
53
enable:
6-
- bodyclose
7-
- gofumpt
8-
- goimports
9-
- gci
10-
- importas
11-
- revive
12-
- gosec
13-
- misspell
14-
- unconvert
15-
- unparam
16-
- goheader
17-
- gocritic
18-
- forbidigo
19-
- testifylint
20-
- ginkgolinter
21-
22-
linters-settings:
23-
misspell:
24-
ignore-words:
25-
- clas
26-
- cancelled
27-
locale: US
28-
unparam:
29-
check-exported: false
30-
goheader:
31-
template-path: ./hack/license-template.txt
32-
forbidigo:
33-
forbid:
34-
- http.DefaultTransport
35-
revive:
4+
- bodyclose
5+
- forbidigo
6+
- ginkgolinter
7+
- gocritic
8+
- goheader
9+
- gosec
10+
- importas
11+
- misspell
12+
- revive
13+
- testifylint
14+
- unconvert
15+
- unparam
16+
settings:
17+
forbidigo:
18+
forbid:
19+
- pattern: http.DefaultTransport
20+
ginkgolinter:
21+
forbid-focus-container: true
22+
goheader:
23+
template-path: ./hack/license-template.txt
24+
importas:
25+
alias:
26+
- pkg: github.com/projectcontour/contour/apis/projectcontour/(v\w+)
27+
alias: contour_${1}
28+
- pkg: sigs.k8s.io/gateway-api/apis/(v\w+)
29+
alias: gatewayapi_${1}
30+
- pkg: k8s.io.*/apis?/(\w+)/(v\w+)
31+
alias: ${1}_${2}
32+
- pkg: github.com/envoyproxy/go-control-plane/envoy/config/(\w+)/(v\w+)
33+
alias: envoy_config_${1}_${2}
34+
- pkg: github.com/envoyproxy/go-control-plane/envoy/service/(\w+)/(v\w+)
35+
alias: envoy_service_${1}_${2}
36+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/filters/(\w+)/(\w+)/(v\w+)
37+
alias: envoy_filter_${1}_${2}_${3}
38+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/(\w+)/(v\w+)
39+
alias: envoy_transport_socket_${1}_${2}
40+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/compression/(\w+)/(\w+)/(v\w+)
41+
alias: envoy_compression_${1}_${2}_${3}
42+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/(\w+)/(v\w+)
43+
alias: envoy_access_logger_${1}_${2}
44+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/formatter/(\w+)/(v\w+)
45+
alias: envoy_formatter_${1}_${2}
46+
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/upstreams/(\w+)/(v\w+)
47+
alias: envoy_upstream_${1}_${2}
48+
- pkg: github.com/envoyproxy/go-control-plane/envoy/type/(v\w+)
49+
alias: envoy_type_${1}
50+
- pkg: github.com/envoyproxy/go-control-plane/envoy/type/matcher/(v\w+)
51+
alias: envoy_matcher_${1}
52+
no-unaliased: true
53+
misspell:
54+
locale: US
55+
ignore-rules:
56+
- clas
57+
- cancelled
58+
revive:
59+
rules:
60+
- name: blank-imports
61+
- name: context-as-argument
62+
- name: context-keys-type
63+
- name: dot-imports
64+
- name: empty-block
65+
- name: error-naming
66+
- name: error-return
67+
- name: error-strings
68+
- name: errorf
69+
- name: exported
70+
- name: increment-decrement
71+
- name: indent-error-flow
72+
- name: package-comments
73+
- name: range
74+
- name: receiver-naming
75+
- name: redefines-builtin-id
76+
- name: superfluous-else
77+
- name: time-naming
78+
- name: unexported-return
79+
- name: unreachable-code
80+
- name: unused-parameter
81+
- name: use-any
82+
- name: var-declaration
83+
- name: var-naming
84+
testifylint:
85+
enable-all: true
86+
unparam:
87+
check-exported: false
88+
exclusions:
89+
generated: lax
90+
presets:
91+
- comments
92+
- common-false-positives
93+
- legacy
94+
- std-error-handling
3695
rules:
37-
- name: blank-imports
38-
- name: context-as-argument
39-
- name: context-keys-type
40-
- name: dot-imports
41-
- name: empty-block
42-
- name: error-naming
43-
- name: error-return
44-
- name: error-strings
45-
- name: errorf
46-
- name: exported
47-
- name: increment-decrement
48-
- name: indent-error-flow
49-
- name: package-comments
50-
- name: range
51-
- name: receiver-naming
52-
- name: redefines-builtin-id
53-
- name: superfluous-else
54-
- name: time-naming
55-
- name: unexported-return
56-
- name: unreachable-code
57-
- name: unused-parameter
58-
- name: use-any
59-
- name: var-declaration
60-
- name: var-naming
61-
testifylint:
62-
enable-all: true
63-
ginkgolinter:
64-
forbid-focus-container: true
65-
gofumpt:
66-
extra-rules: true
67-
gci:
68-
custom-order: true
69-
sections:
70-
- standard
71-
- default
72-
- prefix(github.com/projectcontour/contour)
73-
importas:
74-
no-unaliased: true
75-
alias:
76-
- pkg: github.com/projectcontour/contour/apis/projectcontour/(v\w+)
77-
alias: contour_${1}
78-
- pkg: sigs.k8s.io/gateway-api/apis/(v\w+)
79-
alias: gatewayapi_${1}
80-
- pkg: k8s.io.*/apis?/(\w+)/(v\w+)
81-
alias: ${1}_${2}
82-
- pkg: github.com/envoyproxy/go-control-plane/envoy/config/(\w+)/(v\w+)
83-
alias: envoy_config_${1}_${2}
84-
- pkg: github.com/envoyproxy/go-control-plane/envoy/service/(\w+)/(v\w+)
85-
alias: envoy_service_${1}_${2}
86-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/filters/(\w+)/(\w+)/(v\w+)
87-
alias: envoy_filter_${1}_${2}_${3}
88-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/(\w+)/(v\w+)
89-
alias: envoy_transport_socket_${1}_${2}
90-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/compression/(\w+)/(\w+)/(v\w+)
91-
alias: envoy_compression_${1}_${2}_${3}
92-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/(\w+)/(v\w+)
93-
alias: envoy_access_logger_${1}_${2}
94-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/formatter/(\w+)/(v\w+)
95-
alias: envoy_formatter_${1}_${2}
96-
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/upstreams/(\w+)/(v\w+)
97-
alias: envoy_upstream_${1}_${2}
98-
- pkg: github.com/envoyproxy/go-control-plane/envoy/type/(v\w+)
99-
alias: envoy_type_${1}
100-
- pkg: github.com/envoyproxy/go-control-plane/envoy/type/matcher/(v\w+)
101-
alias: envoy_matcher_${1}
102-
96+
- linters:
97+
- unparam
98+
text: always receives
99+
- linters:
100+
- bodyclose
101+
path: test/e2e
102+
- linters:
103+
- revive
104+
path: test/e2e
105+
text: should not use dot imports
106+
- linters:
107+
- testifylint
108+
path: test/e2e
109+
text: require must only be used in the goroutine running the test function
110+
paths:
111+
- third_party$
112+
- builtin$
113+
- examples$
103114
issues:
104115
max-issues-per-linter: 0
105116
max-same-issues: 0
106-
exclude-rules:
107-
- linters: ["unparam"]
108-
text: "always receives"
109-
- path: zz_generated
110-
linters: ["goimports"]
111-
- path: test/e2e
112-
linters: ["bodyclose"]
113-
- path: test/e2e
114-
linters: ["revive"]
115-
text: "should not use dot imports"
116-
- path: test/e2e
117-
linters: ["testifylint"]
118-
text: "require must only be used in the goroutine running the test function"
117+
formatters:
118+
enable:
119+
- gci
120+
- gofumpt
121+
- goimports
122+
settings:
123+
gci:
124+
sections:
125+
- standard
126+
- default
127+
- prefix(github.com/projectcontour/contour)
128+
custom-order: true
129+
gofumpt:
130+
extra-rules: true
131+
exclusions:
132+
generated: lax
133+
paths:
134+
- third_party$
135+
- builtin$
136+
- examples$
137+
- zz_generated

hack/golangci-lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#! /usr/bin/env bash
22

3-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5 "$@"
3+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 "$@"

0 commit comments

Comments
 (0)