Skip to content

Commit b609821

Browse files
Upgrade GolangCI-Lint to Latest Version (v2.0.2)
1 parent 5307272 commit b609821

File tree

18 files changed

+31
-39
lines changed

18 files changed

+31
-39
lines changed

.github/workflows/lint-sample.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
working-directory: ${{ matrix.folder }}
3737
run: make lint-config
3838
- name: Run linter
39-
uses: golangci/golangci-lint-action@v6
39+
uses: golangci/golangci-lint-action@v7
4040
with:
41-
version: v1.63.4
41+
version: v2.0.2
4242
working-directory: ${{ matrix.folder }}
4343
args: --config .golangci.yml ./...
4444
- name: Run linter via makefile target

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
- name: Check linter configuration
2525
run: make lint-config
2626
- name: Run linter
27-
uses: golangci/golangci-lint-action@v6
27+
uses: golangci/golangci-lint-action@v7
2828
with:
29-
version: v1.63.4
29+
version: v2.0.2
3030

3131
yamllint:
3232
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
version: 2
12
run:
23
timeout: 5m
34
allow-parallel-runners: true
45

56
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
87
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
118
exclude-rules:
129
- linters: [gosec]
1310
path: "test/e2e/*"
@@ -26,13 +23,11 @@ linters-settings:
2623
allow-unused: false
2724
revive:
2825
rules:
29-
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
3026
- name: blank-imports
3127
- name: context-as-argument
3228
- name: context-keys-type
3329
- name: dot-imports
3430
arguments:
35-
# dot import should be ONLY allowed for ginkgo testing packages
3631
- allowedPackages:
3732
- "github.com/onsi/ginkgo/v2"
3833
- "github.com/onsi/gomega"
@@ -45,7 +40,7 @@ linters-settings:
4540
- name: var-naming
4641
- name: var-declaration
4742
- name: package-comments
48-
disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings.
43+
disabled: true
4944
- name: range
5045
- name: receiver-naming
5146
- name: time-naming
@@ -57,9 +52,6 @@ linters-settings:
5752
- name: unused-parameter
5853
- name: unreachable-code
5954
- name: redefines-builtin-id
60-
#
61-
# Rules in addition to the recommended configuration above.
62-
#
6355
- name: bool-literal-in-expr
6456
- name: constant-logical-expr
6557
- name: comment-spacings
@@ -73,9 +65,6 @@ linters:
7365
- ginkgolinter
7466
- goconst
7567
- gocyclo
76-
- gofmt
77-
- goimports
78-
- gosimple
7968
- govet
8069
- ineffassign
8170
- lll
@@ -85,8 +74,11 @@ linters:
8574
- prealloc
8675
- revive
8776
- staticcheck
88-
- typecheck
8977
- unconvert
9078
- unparam
9179
- unused
9280

81+
formatters:
82+
enable:
83+
- gofmt
84+
- goimports

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
125125
golangci-lint:
126126
@[ -f $(GOLANGCI_LINT) ] || { \
127127
set -e ;\
128-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.63.4 ;\
128+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v2.0.2 ;\
129129
}
130130

131131
.PHONY: apidiff

docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
182182
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
183183
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
184184
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
185-
GOLANGCI_LINT_VERSION ?= v1.63.4
185+
GOLANGCI_LINT_VERSION ?= v2.0.2
186186

187187
.PHONY: kustomize
188188
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -210,7 +210,7 @@ $(ENVTEST): $(LOCALBIN)
210210
.PHONY: golangci-lint
211211
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
212212
$(GOLANGCI_LINT): $(LOCALBIN)
213-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
213+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
214214

215215
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
216216
# $1 - target path with name of binary

docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

docs/book/src/getting-started/testdata/project/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
178178
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
179179
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
180180
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
181-
GOLANGCI_LINT_VERSION ?= v1.63.4
181+
GOLANGCI_LINT_VERSION ?= v2.0.2
182182

183183
.PHONY: kustomize
184184
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -206,7 +206,7 @@ $(ENVTEST): $(LOCALBIN)
206206
.PHONY: golangci-lint
207207
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
208208
$(GOLANGCI_LINT): $(LOCALBIN)
209-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
209+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
210210

211211
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
212212
# $1 - target path with name of binary

docs/book/src/multiversion-tutorial/testdata/project/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

docs/book/src/multiversion-tutorial/testdata/project/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
182182
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
183183
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
184184
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
185-
GOLANGCI_LINT_VERSION ?= v1.63.4
185+
GOLANGCI_LINT_VERSION ?= v2.0.2
186186

187187
.PHONY: kustomize
188188
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -210,7 +210,7 @@ $(ENVTEST): $(LOCALBIN)
210210
.PHONY: golangci-lint
211211
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
212212
$(GOLANGCI_LINT): $(LOCALBIN)
213-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
213+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
214214

215215
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
216216
# $1 - target path with name of binary

pkg/plugins/golang/v4/scaffolds/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838

3939
const (
4040
// GolangciLintVersion is the golangci-lint version to be used in the project
41-
GolangciLintVersion = "v1.63.4"
41+
GolangciLintVersion = "v2.0.2"
4242
// ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project
4343
ControllerRuntimeVersion = "v0.20.4"
4444
// ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project

pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ $(ENVTEST): $(LOCALBIN)
285285
.PHONY: golangci-lint
286286
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
287287
$(GOLANGCI_LINT): $(LOCALBIN)
288-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
288+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
289289
290290
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
291291
# $1 - target path with name of binary

testdata/project-v4-multigroup/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

testdata/project-v4-multigroup/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
178178
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
179179
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
180180
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
181-
GOLANGCI_LINT_VERSION ?= v1.63.4
181+
GOLANGCI_LINT_VERSION ?= v2.0.2
182182

183183
.PHONY: kustomize
184184
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -206,7 +206,7 @@ $(ENVTEST): $(LOCALBIN)
206206
.PHONY: golangci-lint
207207
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
208208
$(GOLANGCI_LINT): $(LOCALBIN)
209-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
209+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
210210

211211
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
212212
# $1 - target path with name of binary

testdata/project-v4-with-plugins/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

testdata/project-v4-with-plugins/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
178178
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
179179
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
180180
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
181-
GOLANGCI_LINT_VERSION ?= v1.63.4
181+
GOLANGCI_LINT_VERSION ?= v2.0.2
182182

183183
.PHONY: kustomize
184184
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -206,7 +206,7 @@ $(ENVTEST): $(LOCALBIN)
206206
.PHONY: golangci-lint
207207
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
208208
$(GOLANGCI_LINT): $(LOCALBIN)
209-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
209+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
210210

211211
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
212212
# $1 - target path with name of binary

testdata/project-v4/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

testdata/project-v4/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.17.2
178178
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
179179
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
180180
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
181-
GOLANGCI_LINT_VERSION ?= v1.63.4
181+
GOLANGCI_LINT_VERSION ?= v2.0.2
182182

183183
.PHONY: kustomize
184184
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -206,7 +206,7 @@ $(ENVTEST): $(LOCALBIN)
206206
.PHONY: golangci-lint
207207
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
208208
$(GOLANGCI_LINT): $(LOCALBIN)
209-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
209+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
210210

211211
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
212212
# $1 - target path with name of binary

0 commit comments

Comments
 (0)