Skip to content

Commit 4f114a2

Browse files
authored
Merge pull request #779 from anmazzotti/bump_golangci-lint-v2
🌱 Bump golangci-lint to v2
2 parents 5a17df2 + cb3e021 commit 4f114a2

File tree

8 files changed

+162
-142
lines changed

8 files changed

+162
-142
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ jobs:
2121
with:
2222
go-version: ${{ steps.vars.outputs.go_version }}
2323
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
24+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # tag=v7.0.0
2525
with:
26-
version: v1.63.3
26+
version: v2.0.2
2727
args: --timeout 15m
2828
- name: golangci-lint-test
29-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
29+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # tag=v7.0.0
3030
with:
31-
version: v1.63.3
31+
version: v2.0.2
3232
args: --build-tags e2e --timeout 15m
3333
working-directory: test

.golangci.yaml

Lines changed: 126 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,34 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
go: "1.23"
44
allow-parallel-runners: true
5-
65
linters:
7-
disable-all: true
8-
# Enable specific linter
9-
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
6+
default: none
107
enable:
11-
# Default linters
12-
- errcheck
13-
- gosimple
14-
- govet
15-
- ineffassign
16-
- staticcheck
17-
- typecheck
18-
- unused
19-
# Additional linters
208
- asasalint
219
- asciicheck
2210
- bidichk
2311
- bodyclose
2412
- contextcheck
13+
- copyloopvar
2514
- dogsled
2615
- durationcheck
16+
- errcheck
2717
- errname
2818
- errorlint
2919
- exhaustive
30-
- copyloopvar
3120
- forcetypeassert
3221
- ginkgolinter
3322
- goconst
3423
- gocritic
3524
- gocyclo
3625
- godot
37-
- gofmt
38-
- gofumpt
3926
- goheader
40-
- goimports
4127
- goprintffuncname
4228
- gosec
29+
- govet
4330
- importas
31+
- ineffassign
4432
- makezero
4533
- misspell
4634
- nakedret
@@ -56,105 +44,137 @@ linters:
5644
- reassign
5745
- rowserrcheck
5846
- sqlclosecheck
59-
- stylecheck
47+
- staticcheck
6048
- tagliatelle
61-
- tenv
6249
- testableexamples
6350
- thelper
6451
- tparallel
6552
- unconvert
6653
- unparam
54+
- unused
6755
- usestdlibvars
6856
- wastedassign
6957
- whitespace
7058
- wsl
59+
settings:
60+
goheader:
61+
values:
62+
regexp:
63+
license-year: (202[0-9]|20[3-9][0-9])
64+
template: |-
65+
Copyright {{license-year}} The Kubernetes Authors.
7166
72-
linters-settings:
73-
goheader:
74-
values:
75-
regexp:
76-
license-year: (202[0-9]|20[3-9][0-9])
77-
template: |-
78-
Copyright {{license-year}} The Kubernetes Authors.
67+
Licensed under the Apache License, Version 2.0 (the "License");
68+
you may not use this file except in compliance with the License.
69+
You may obtain a copy of the License at
7970
80-
Licensed under the Apache License, Version 2.0 (the "License");
81-
you may not use this file except in compliance with the License.
82-
You may obtain a copy of the License at
71+
http://www.apache.org/licenses/LICENSE-2.0
8372
84-
http://www.apache.org/licenses/LICENSE-2.0
85-
86-
Unless required by applicable law or agreed to in writing, software
87-
distributed under the License is distributed on an "AS IS" BASIS,
88-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89-
See the License for the specific language governing permissions and
90-
limitations under the License.
91-
nlreturn:
92-
block-size: 2
93-
revive:
94-
confidence: 0
73+
Unless required by applicable law or agreed to in writing, software
74+
distributed under the License is distributed on an "AS IS" BASIS,
75+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76+
See the License for the specific language governing permissions and
77+
limitations under the License.
78+
importas:
79+
alias:
80+
# Kubernetes
81+
- pkg: k8s.io/api/core/v1
82+
alias: corev1
83+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
84+
alias: apiextensionsv1
85+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
86+
alias: metav1
87+
- pkg: k8s.io/apimachinery/pkg/api/errors
88+
alias: apierrors
89+
- pkg: k8s.io/apimachinery/pkg/util/errors
90+
alias: kerrors
91+
- pkg: k8s.io/apimachinery/pkg/util/runtime
92+
alias: utilruntime
93+
# Controller Runtime
94+
- pkg: sigs.k8s.io/controller-runtime
95+
alias: ctrl
96+
# CAPI
97+
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
98+
alias: clusterv1
99+
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3
100+
alias: clusterctlv1
101+
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
102+
alias: configclient
103+
# CAPI Operator
104+
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha1
105+
alias: operatorv1alpha1
106+
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha2
107+
alias: operatorv1
108+
- pkg: sigs.k8s.io/cluster-api-operator/internal/controller
109+
alias: providercontroller
110+
no-unaliased: true
111+
nlreturn:
112+
block-size: 2
113+
revive:
114+
confidence: 0
115+
rules:
116+
- name: exported
117+
arguments:
118+
- checkPrivateReceivers
119+
- disableStutteringCheck
120+
severity: warning
121+
disabled: false
122+
staticcheck:
123+
# https://staticcheck.io/docs/options#checks
124+
checks:
125+
- -ST1000
126+
- -ST1003
127+
- -ST1016
128+
- all
129+
dot-import-whitelist:
130+
- github.com/onsi/gomega
131+
exclusions:
132+
generated: lax
95133
rules:
96-
- name: exported
97-
severity: warning
98-
disabled: false
99-
arguments:
100-
- "checkPrivateReceivers"
101-
- "disableStutteringCheck"
102-
stylecheck:
103-
# https://staticcheck.io/docs/options#checks
104-
checks: ["all", "-ST1000", "-ST1003", "-ST1016"]
105-
dot-import-whitelist:
106-
- "github.com/onsi/gomega"
107-
importas:
108-
no-unaliased: true
109-
alias:
110-
# Kubernetes
111-
- pkg: k8s.io/api/core/v1
112-
alias: corev1
113-
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
114-
alias: apiextensionsv1
115-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
116-
alias: metav1
117-
- pkg: k8s.io/apimachinery/pkg/api/errors
118-
alias: apierrors
119-
- pkg: k8s.io/apimachinery/pkg/util/errors
120-
alias: kerrors
121-
- pkg: k8s.io/apimachinery/pkg/util/runtime
122-
alias: utilruntime
123-
# Controller Runtime
124-
- pkg: sigs.k8s.io/controller-runtime
125-
alias: ctrl
126-
# CAPI
127-
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
128-
alias: clusterv1
129-
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3
130-
alias: clusterctlv1
131-
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
132-
alias: configclient
133-
# CAPI Operator
134-
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha1
135-
alias: operatorv1alpha1
136-
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha2
137-
alias: operatorv1
138-
- pkg: sigs.k8s.io/cluster-api-operator/internal/controller
139-
alias: providercontroller
140-
issues:
141-
exclude:
142-
# Not all platforms are supported by this operator, those which aren't
143-
# supported will be caught by the default case in the switches.
144-
- "missing cases in switch of type v1.PlatformType: (\\.*)"
145-
exclude-use-default: false
146-
exclude-files:
147-
- "zz_generated.*\\.go$"
148-
exclude-rules:
149-
- linters:
150-
- staticcheck
151-
text: "SA1019: (\"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1\"|ctrlconfigv1.*) is deprecated: The component config package has been deprecated and will be removed in a future release."
152-
# Exclude some linters from running on tests files.
153-
- path: _test\.go
154-
linters:
155-
- gosec
156-
- path: internal/envtest/environment.go
157-
linters:
158-
- dogsled
159-
- gosec
160-
- wsl
134+
- linters:
135+
- staticcheck
136+
text: 'SA1019: ("sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"|ctrlconfigv1.*) is deprecated: The component config package has been deprecated and will be removed in a future release.'
137+
- linters:
138+
- staticcheck
139+
text: 'ST1016: methods on the same type should have the same receiver name'
140+
path: api/(.+)\.go$
141+
- linters:
142+
- staticcheck
143+
text: 'ST1003: should not use underscores in Go names;'
144+
path: api/(.+)\.go$
145+
- linters:
146+
- staticcheck
147+
text: 'QF1008: could remove embedded field'
148+
- linters:
149+
- staticcheck
150+
text: 'ST1000: at least one file in a package should have a package comment'
151+
# Exclude some linters from running on tests files.
152+
- linters:
153+
- gosec
154+
path: _test\.go
155+
- linters:
156+
- dogsled
157+
- gosec
158+
- wsl
159+
path: internal/envtest/environment.go
160+
# Not all platforms are supported by this operator, those which aren't
161+
# supported will be caught by the default case in the switches.
162+
- path: (.+)\.go$
163+
text: 'missing cases in switch of type v1.PlatformType: (\.*)'
164+
paths:
165+
- zz_generated.*\.go$
166+
- third_party$
167+
- builtin$
168+
- examples$
169+
formatters:
170+
enable:
171+
- gofmt
172+
- gofumpt
173+
- goimports
174+
exclusions:
175+
generated: lax
176+
paths:
177+
- zz_generated.*\.go$
178+
- third_party$
179+
- builtin$
180+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ CONTROLLER_GEN_VER := v0.16.1
8383
CONTROLLER_GEN_BIN := controller-gen
8484
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
8585

86-
GOLANGCI_LINT_VER := v1.63.3
86+
GOLANGCI_LINT_VER := v2.0.2
8787
GOLANGCI_LINT_BIN := golangci-lint
8888
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
8989

@@ -235,7 +235,7 @@ $(GOTESTSUM): # Build gotestsum from tools folder.
235235
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) gotest.tools/gotestsum $(GOTESTSUM_BIN) $(GOTESTSUM_VER)
236236

237237
$(GOLANGCI_LINT): ## Build golangci-lint from tools folder.
238-
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
238+
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/v2/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
239239

240240
$(HELM): ## Put helm into tools folder.
241241
mkdir -p $(TOOLS_BIN_DIR)

0 commit comments

Comments
 (0)