Skip to content

Commit 4188fa9

Browse files
committed
complete golangci upgrade
removed goinstall prefix and path
1 parent fa1d379 commit 4188fa9

File tree

23 files changed

+290
-269
lines changed

23 files changed

+290
-269
lines changed

.github/workflows/lint-sample.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +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-
install-mode: goinstall
42-
version: v1.63.4
41+
version: v2.0.2
4342
working-directory: ${{ matrix.folder }}
4443
args: --config .golangci.yml ./...
4544
- name: Run linter via makefile target

.github/workflows/lint.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +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-
install-mode: goinstall
30-
version: v1.63.4
29+
version: v2.0.2
3130

3231
yamllint:
3332
runs-on: ubuntu-latest

.golangci.yml

+74-75
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,97 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- linters: [gosec]
13-
path: "test/e2e/*"
14-
- path: "hack/docs/*"
15-
linters:
16-
- lll
17-
- gosec
18-
19-
linters-settings:
20-
ginkgolinter:
21-
forbid-focus-container: true
22-
forbid-spec-pollution: true
23-
govet:
24-
enable-all: true
25-
disable:
26-
- fieldalignment
27-
nolintlint:
28-
allow-unused: false
29-
revive:
30-
rules:
31-
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
32-
- name: blank-imports
33-
- name: context-as-argument
34-
- name: context-keys-type
35-
- name: dot-imports
36-
arguments:
37-
# dot import should be ONLY allowed for ginkgo testing packages
38-
- allowedPackages:
39-
- "github.com/onsi/ginkgo/v2"
40-
- "github.com/onsi/gomega"
41-
- name: error-return
42-
- name: error-strings
43-
- name: error-naming
44-
- name: exported
45-
- name: if-return
46-
- name: import-shadowing
47-
- name: increment-decrement
48-
- name: var-naming
49-
- name: var-declaration
50-
- name: package-comments
51-
disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings.
52-
- name: range
53-
- name: receiver-naming
54-
- name: time-naming
55-
- name: unexported-return
56-
- name: indent-error-flow
57-
- name: errorf
58-
- name: empty-block
59-
- name: superfluous-else
60-
- name: unused-parameter
61-
- name: unreachable-code
62-
- name: redefines-builtin-id
63-
#
64-
# Rules in addition to the recommended configuration above.
65-
#
66-
- name: bool-literal-in-expr
67-
- name: constant-logical-expr
68-
- name: comment-spacings
694
linters:
70-
disable-all: true
5+
default: none
716
enable:
727
- asciicheck
738
- bidichk
9+
- copyloopvar
7410
- dupl
7511
- errcheck
76-
- copyloopvar
7712
- ginkgolinter
7813
- goconst
7914
- gocyclo
80-
- gofmt
81-
- gofumpt
82-
- goimports
83-
- gosimple
8415
- govet
8516
- ineffassign
8617
- lll
8718
- misspell
88-
- nolintlint
8919
- nakedret
20+
- nolintlint
9021
- prealloc
9122
- revive
9223
- staticcheck
93-
- typecheck
9424
- unconvert
9525
- unparam
9626
- unused
9727
- whitespace
98-
28+
settings:
29+
ginkgolinter:
30+
forbid-focus-container: true
31+
forbid-spec-pollution: true
32+
govet:
33+
disable:
34+
- fieldalignment
35+
enable-all: true
36+
nolintlint:
37+
allow-unused: false
38+
revive:
39+
rules:
40+
- name: blank-imports
41+
- name: context-as-argument
42+
- name: context-keys-type
43+
- name: dot-imports
44+
arguments:
45+
- allowedPackages:
46+
- github.com/onsi/ginkgo/v2
47+
- github.com/onsi/gomega
48+
- name: error-return
49+
- name: error-strings
50+
- name: error-naming
51+
- name: exported
52+
- name: if-return
53+
- name: import-shadowing
54+
- name: increment-decrement
55+
- name: var-naming
56+
- name: var-declaration
57+
- name: package-comments
58+
disabled: true
59+
- name: range
60+
- name: receiver-naming
61+
- name: time-naming
62+
- name: unexported-return
63+
- name: indent-error-flow
64+
- name: errorf
65+
- name: empty-block
66+
- name: superfluous-else
67+
- name: unused-parameter
68+
- name: unreachable-code
69+
- name: redefines-builtin-id
70+
- name: bool-literal-in-expr
71+
- name: constant-logical-expr
72+
- name: comment-spacings
73+
exclusions:
74+
generated: lax
75+
rules:
76+
- linters:
77+
- gosec
78+
path: test/e2e/*
79+
- linters:
80+
- gosec
81+
- lll
82+
path: hack/docs/*
83+
paths:
84+
- third_party$
85+
- builtin$
86+
- examples$
87+
formatters:
88+
enable:
89+
- gofmt
90+
- gofumpt
91+
- goimports
92+
exclusions:
93+
generated: lax
94+
paths:
95+
- third_party$
96+
- builtin$
97+
- examples$

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ yamllint:
124124
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
125125
golangci-lint:
126126
@[ -f $(GOLANGCI_LINT) ] || { \
127-
GOBIN=$(shell pwd)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4 ;\
127+
GOBIN=$(shell pwd)/bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 ;\
128128
}
129129

130130
.PHONY: apidiff

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
go-version-file: go.mod
1919

2020
- name: Run linter
21-
uses: golangci/golangci-lint-action@v6
21+
uses: golangci/golangci-lint-action@v7
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
allow-parallel-runners: true
4-
5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
11-
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
16-
linters:
17-
- dupl
18-
- lll
194
linters:
20-
disable-all: true
5+
default: none
216
enable:
7+
- copyloopvar
228
- dupl
239
- errcheck
24-
- copyloopvar
2510
- ginkgolinter
2611
- goconst
2712
- gocyclo
28-
- gofmt
29-
- goimports
30-
- gosimple
3113
- govet
3214
- ineffassign
3315
- lll
@@ -36,13 +18,35 @@ linters:
3618
- prealloc
3719
- revive
3820
- staticcheck
39-
- typecheck
4021
- unconvert
4122
- unparam
4223
- unused
43-
44-
linters-settings:
45-
revive:
24+
settings:
25+
revive:
26+
rules:
27+
- name: comment-spacings
28+
- name: import-shadowing
29+
exclusions:
30+
generated: lax
4631
rules:
47-
- name: comment-spacings
48-
- name: import-shadowing
32+
- linters:
33+
- lll
34+
path: api/*
35+
- linters:
36+
- dupl
37+
- lll
38+
path: internal/*
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$
43+
formatters:
44+
enable:
45+
- gofmt
46+
- goimports
47+
exclusions:
48+
generated: lax
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$

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

+2-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
go-version-file: go.mod
1919

2020
- name: Run linter
21-
uses: golangci/golangci-lint-action@v6
21+
uses: golangci/golangci-lint-action@v7
2222
with:
23-
version: v1.63.4
23+
version: v2.0.2

0 commit comments

Comments
 (0)