Skip to content

Commit 905c1ca

Browse files
authored
Merge pull request kubernetes-sigs#65 from sivchari/migrate-golangci-lint-v2
Migrate golangci lint v2
2 parents 4aee8ba + 12d4eff commit 905c1ca

File tree

1,403 files changed

+113681
-41680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,403 files changed

+113681
-41680
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v1.62.0
1+
version: v2.0.2
22
name: golangci-kube-api-linter
33
destination: ./bin
44
plugins:

.github/workflows/golangci-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
with:
2121
go-version: '1.23.x'
2222
- name: golangci-lint
23-
uses: golangci/golangci-lint-action@v6
23+
uses: golangci/golangci-lint-action@v7
2424
with:
25-
version: v1.62
25+
version: v2.0.2

.golangci.yaml

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1+
version: "2"
12
linters:
2-
disable-all: true
3+
default: none
34
# Enable specific linter
45
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
56
enable:
6-
# Default linters
7-
- errcheck
8-
- gosimple
9-
- govet
10-
- ineffassign
11-
- staticcheck
12-
- typecheck
13-
- unused
14-
# Additional linters
157
- asciicheck
168
- bidichk
179
- bodyclose
@@ -20,10 +12,11 @@ linters:
2012
- dogsled
2113
- dupl
2214
- durationcheck
15+
- err113
16+
- errcheck
2317
- errname
2418
- errorlint
2519
- exhaustive
26-
- exportloopref
2720
- forcetypeassert
2821
- funlen
2922
- gochecknoglobals
@@ -32,13 +25,12 @@ linters:
3225
- gocritic
3326
- gocyclo
3427
- godot
35-
- goerr113
36-
- gofmt
3728
- goheader
38-
- goimports
3929
- goprintffuncname
4030
- gosec
31+
- govet
4132
- importas
33+
- ineffassign
4234
- makezero
4335
- misspell
4436
- nakedret
@@ -51,66 +43,81 @@ linters:
5143
- prealloc
5244
- predeclared
5345
- revive
54-
- stylecheck
46+
- staticcheck
5547
- tagliatelle
56-
- tenv
5748
- unconvert
5849
- unparam
50+
- unused
5951
- wastedassign
6052
- whitespace
6153
- wrapcheck
6254
- wsl
63-
linters-settings:
64-
goheader:
65-
values:
66-
regexp:
67-
license-year: (202[5-9]|20[3-9][0-9])
68-
template: |-
69-
Copyright {{license-year}} The Kubernetes Authors.
55+
settings:
56+
goheader:
57+
values:
58+
regexp:
59+
license-year: (202[5-9]|20[3-9][0-9])
60+
template: |-
61+
Copyright {{license-year}} The Kubernetes Authors.
7062
71-
Licensed under the Apache License, Version 2.0 (the "License");
72-
you may not use this file except in compliance with the License.
73-
You may obtain a copy of the License at
63+
Licensed under the Apache License, Version 2.0 (the "License");
64+
you may not use this file except in compliance with the License.
65+
You may obtain a copy of the License at
7466
75-
http://www.apache.org/licenses/LICENSE-2.0
67+
http://www.apache.org/licenses/LICENSE-2.0
7668
77-
Unless required by applicable law or agreed to in writing, software
78-
distributed under the License is distributed on an "AS IS" BASIS,
79-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80-
See the License for the specific language governing permissions and
81-
limitations under the License.
82-
nlreturn:
83-
block-size: 2
84-
revive:
85-
confidence: 0
86-
rules:
87-
- name: exported
88-
severity: warning
89-
disabled: false
90-
arguments:
91-
- "checkPrivateReceivers"
92-
- "disableStutteringCheck"
93-
stylecheck:
94-
# https://staticcheck.io/docs/options#checks
95-
checks: ["all", "-ST1000"]
96-
dot-import-whitelist:
97-
- "github.com/onsi/ginkgo/v2"
98-
- "github.com/onsi/gomega"
99-
issues:
100-
exclude:
101-
- Analyzer is a global variable
102-
exclude-use-default: false
103-
exclude-rules:
104-
# Exclude some linters from running on tests files.
105-
- path: _test\.go
106-
linters:
107-
- gocyclo
108-
- dupl
109-
- gosec
110-
- gochecknoglobals
111-
- goerr113
112-
- funlen
113-
- path: testdata
114-
linters:
69+
Unless required by applicable law or agreed to in writing, software
70+
distributed under the License is distributed on an "AS IS" BASIS,
71+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72+
See the License for the specific language governing permissions and
73+
limitations under the License.
74+
nlreturn:
75+
block-size: 2
76+
revive:
77+
confidence: 0
78+
rules:
79+
- name: exported
80+
arguments:
81+
- checkPrivateReceivers
82+
- disableStutteringCheck
83+
severity: warning
84+
disabled: false
85+
staticcheck:
86+
# https://staticcheck.io/docs/options#checks
87+
checks:
11588
- all
116-
89+
- -ST1000
90+
dot-import-whitelist:
91+
- github.com/onsi/ginkgo/v2
92+
- github.com/onsi/gomega
93+
exclusions:
94+
generated: lax
95+
rules:
96+
- linters:
97+
- dupl
98+
- err113
99+
- funlen
100+
- gochecknoglobals
101+
- gocyclo
102+
- gosec
103+
# Exclude some linters from running on tests files.
104+
path: _test\.go
105+
- linters:
106+
- all
107+
path: testdata
108+
- path: (.+)\.go$
109+
text: Analyzer is a global variable
110+
paths:
111+
- third_party$
112+
- builtin$
113+
- examples$
114+
formatters:
115+
enable:
116+
- gofmt
117+
- goimports
118+
exclusions:
119+
generated: lax
120+
paths:
121+
- third_party$
122+
- builtin$
123+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
2-
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
2+
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint
33

44
VERSION ?= $(shell git describe --always --abbrev=7)
55

@@ -44,7 +44,7 @@ lint: ## Run golangci-lint over the codebase.
4444
${GOLANGCI_LINT} run ./... --timeout 5m -v
4545

4646
.PHONY: lint-fix
47-
lint-fix: $(GOLANGCI_LINT) ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
47+
lint-fix: ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
4848
${GOLANGCI_LINT} run ./... --timeout 5m -v --fix
4949

5050
.PHONY: test

0 commit comments

Comments
 (0)