Skip to content

Commit e48d099

Browse files
committed
Update golangci-lint to v2.3.1
Golangci-lint has released a new major version that includes some changes to how it is configured, along with the usual linter updates that come with every release. This updates the golangci-lint version we use to v2.3.1 (the current latest release) and updates the config file to conform to the new format. Also includes quite a few trivial updates to address the new warnings from the updated linters. Signed-off-by: Sean McGinnis <[email protected]>
1 parent b12cafe commit e48d099

File tree

26 files changed

+489
-361
lines changed

26 files changed

+489
-361
lines changed

cmd/kind/app/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package app is the implementation of the kind application.
1718
package app
1819

1920
import (

cmd/kind/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package main is the main entrypoint for the kind cli.
1718
package main
1819

1920
import (

hack/make-rules/verify/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ source hack/build/setup-go.sh
2323

2424
# build golangci-lint
2525
cd "${REPO_ROOT}/hack/tools"
26-
go build -o "${REPO_ROOT}"/bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
26+
go build -o "${REPO_ROOT}"/bin/golangci-lint github.com/golangci/golangci-lint/v2/cmd/golangci-lint
2727
cd "${REPO_ROOT}"
2828

2929
# first for the repo in general

hack/tools/.golangci.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,62 @@
1+
version: "2"
2+
13
run:
24
timeout: 3m
35

46
linters:
5-
disable-all: true
7+
default: none
8+
69
enable:
710
- errcheck
8-
- gosimple
911
- govet
1012
- ineffassign
1113
- staticcheck
12-
- typecheck
1314
- gochecknoinits
14-
- gofmt
1515
- revive # replaces golint for now
1616
- misspell
17-
- exportloopref
1817
- unparam
1918

20-
linters-settings:
21-
staticcheck:
22-
checks:
23-
- all
19+
settings:
20+
staticcheck:
21+
checks:
22+
- all
23+
revive:
24+
rules:
25+
- name: var-naming
26+
arguments:
27+
- []
28+
- []
29+
- - skip-package-name-checks: true
30+
31+
exclusions:
32+
presets:
33+
- std-error-handling
34+
- common-false-positives
35+
rules:
36+
# this requires renaming all unused parameters, we'd rather leave a preferred
37+
# placeholder name in place when implementing an interface etc.
38+
# we can revisit this later, right now it's generating a lot of new warnings
39+
# after upgrading golangci-lint
40+
- linters:
41+
- revive
42+
text: "^unused-parameter: .*"
43+
# Not all package docstrings add value, so we do not want to enforce it
44+
- linters:
45+
- revive
46+
text: "package-comments: should have a package comment"
47+
- linters:
48+
- staticcheck
49+
text: "ST1000: at least one file in a package should have a package comment"
50+
- linters:
51+
- staticcheck
52+
path: pkg/cmd
53+
text: "ST1005: error strings should not be capitalized"
54+
- linters:
55+
- staticcheck
56+
path: images/kindnetd/cmd
57+
text: "ST1005: error strings should not be capitalized"
58+
59+
formatters:
60+
enable:
61+
- gofmt
2462

25-
issues:
26-
exclude-rules:
27-
# this requires renaming all unused parameters, we'd rather leave a preferred
28-
# placeholder name in place when implementing an interface etc.
29-
# we can revisit this later, right now it's generating a lot of new warnings
30-
# after upgrading golangci-lint
31-
- text: "^unused-parameter: .*"
32-
linters:
33-
- revive

0 commit comments

Comments
 (0)