Skip to content

Commit 51add5b

Browse files
authored
Merge pull request openshift-kni#1600 from openshift-kni/golangci-lint-2
chore: project: move to golangci-lint v2
2 parents 02ddc81 + 1a6bf0d commit 51add5b

File tree

4 files changed

+105
-101
lines changed

4 files changed

+105
-101
lines changed

.golangci.yml

Lines changed: 97 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,118 @@
1+
version: "2"
12
run:
23
concurrency: 4
3-
timeout: 5m
4-
tests: true
54
modules-download-mode: vendor
6-
issues:
7-
exclude-dirs:
8-
- vendor
9-
- test/utils/k8simported
10-
- pkg/version
11-
# don't skip warning about doc comments
12-
# don't exclude the default set of lint
13-
exclude-use-default: false
14-
# restore some of the defaults
15-
# (fill in the rest as needed)
16-
exclude-rules:
17-
- path: "api/*"
18-
linters:
19-
- gci
20-
- lll
21-
- path: "cmd/*"
22-
linters:
23-
- gci
24-
- path: "internal/*"
25-
linters:
26-
- dupl
27-
- lll
28-
- path: "test/e2e/serial/*"
29-
linters:
30-
- dupl
31-
- lll
32-
- path: "test/utils/*"
33-
linters:
34-
- dupl
35-
- lll
5+
tests: true
366
linters:
37-
disable-all: true
7+
default: none
388
enable:
39-
- errcheck
409
- bodyclose
4110
- copyloopvar
4211
- depguard
43-
- gci
12+
- errcheck
4413
- ginkgolinter
45-
- gosimple
14+
- gocritic
4615
- govet
4716
- ineffassign
4817
- misspell
4918
- nolintlint
5019
- nosprintfhostport
5120
- staticcheck
52-
- typecheck
5321
- unconvert
5422
- unused
5523
- usetesting
5624
- wastedassign
5725
- whitespace
58-
- gocritic
59-
- stylecheck
60-
linters-settings:
61-
gci:
62-
sections:
63-
- standard
64-
- blank
65-
- default
66-
- prefix(k8s.io)
67-
- prefix(sigs.k8s.io)
68-
- prefix(github.com/openshift)
69-
- prefix(github.com/k8stopologyawareschedwg)
70-
- prefix(github.com/openshift-kni)
71-
- dot
72-
custom-order: true
73-
revive:
74-
rules:
75-
- name: comment-spacings
76-
misspell:
77-
locale: US
78-
ignore-words:
79-
- NRO
80-
- nro
81-
- numaresource
82-
- numa
83-
- NUMA
84-
depguard:
26+
settings:
27+
depguard:
28+
rules:
29+
main:
30+
list-mode: original
31+
files:
32+
- $all
33+
- '!$test'
34+
deny:
35+
- pkg: k8s.io/kubernetes
36+
desc: Importing k8s.io/kubernetes as library is not supported
37+
test:
38+
list-mode: lax
39+
files:
40+
- $test
41+
deny:
42+
- pkg: k8s.io/kubernetes
43+
desc: Importing k8s.io/kubernetes as library is not supported
44+
errcheck:
45+
exclude-functions:
46+
- fmt.Fprintf
47+
ginkgolinter:
48+
forbid-focus-container: true
49+
gocritic:
50+
disabled-checks:
51+
- commentFormatting
52+
misspell:
53+
locale: US
54+
ignore-rules:
55+
- NRO
56+
- nro
57+
- numaresource
58+
- numa
59+
- NUMA
60+
revive:
61+
rules:
62+
- name: comment-spacings
63+
staticcheck:
64+
checks:
65+
- ST1008
66+
- ST1019
67+
exclusions:
68+
generated: lax
8569
rules:
86-
main:
87-
list-mode: original
88-
files:
89-
- $all
90-
- "!$test"
91-
deny:
92-
- pkg: "k8s.io/kubernetes"
93-
desc: Importing k8s.io/kubernetes as library is not supported
94-
test:
95-
list-mode: lax
96-
files:
97-
- $test
98-
deny:
99-
- pkg: "k8s.io/kubernetes"
100-
desc: Importing k8s.io/kubernetes as library is not supported
101-
ginkgolinter:
102-
# Trigger warning for ginkgo focus containers like `FDescribe`, `FContext`, `FWhen` or `FIt`
103-
forbid-focus-container: true
104-
errcheck:
105-
exclude-functions:
106-
- fmt.Fprintf
107-
gocritic:
108-
disabled-checks:
109-
- commentFormatting
110-
stylecheck:
111-
checks:
112-
# A function's error value should be its last return value.
113-
# https://staticcheck.dev/docs/checks/#ST1008
114-
- ST1008
115-
# Importing the same package multiple times.
116-
# https://staticcheck.dev/docs/checks/#ST1019
117-
- ST1019
70+
- linters:
71+
- lll
72+
path: api/*
73+
- linters:
74+
- dupl
75+
- lll
76+
path: internal/*
77+
- linters:
78+
- dupl
79+
- lll
80+
path: test/e2e/serial/*
81+
- linters:
82+
- dupl
83+
- lll
84+
path: test/utils/*
85+
paths:
86+
- vendor
87+
- test/utils/k8simported
88+
- pkg/version
89+
- third_party$
90+
- builtin$
91+
- examples$
92+
formatters:
93+
enable:
94+
- gci
95+
settings:
96+
gci:
97+
sections:
98+
- standard
99+
- blank
100+
- default
101+
- prefix(k8s.io)
102+
- prefix(sigs.k8s.io)
103+
- prefix(github.com/openshift)
104+
- prefix(github.com/k8stopologyawareschedwg)
105+
- prefix(github.com/openshift-kni)
106+
- dot
107+
custom-order: true
108+
exclusions:
109+
generated: lax
110+
paths:
111+
- vendor
112+
- test/utils/k8simported
113+
- pkg/version
114+
- third_party$
115+
- builtin$
116+
- examples$
117+
- api/*
118+
- cmd/*

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ sort-imports:
162162

163163
.PHONY: lint
164164
lint: update-buildinfo golangci-lint ## Run golangci-lint linter
165-
$(GOLANGCI_LINT) --verbose run --print-resources-usage --exclude-dirs test/internal/k8simported
165+
$(GOLANGCI_LINT) --verbose run
166166

167167
.PHONY: lint-fix
168168
lint-fix: update-buildinfo golangci-lint ## Run golangci-lint linter and perform fixes
169-
$(GOLANGCI_LINT) --verbose run --print-resources-usage --fix
169+
$(GOLANGCI_LINT) --verbose run --fix
170170

171171
.PHONY: lint-config
172172
lint-config: golangci-lint ## Verify golangci-lint linter configuration
@@ -494,7 +494,7 @@ OPM_VERSION ?= 1.52.0
494494
OPM_BIN = "$(GOOS)-$(GOARCH)-opm"
495495
OPM = "$(LOCALBIN)/$(OPM_BIN)"
496496

497-
GOLANGCI_LINT_VERSION ?= 1.64.6
497+
GOLANGCI_LINT_VERSION ?= 2.2.1
498498
GOLANGCI_LINT_NAME = golangci-lint-$(GOLANGCI_LINT_VERSION)-$(GOOS)-$(GOARCH)
499499
GOLANGCI_LINT_ARTIFACT_FILE = $(GOLANGCI_LINT_NAME).tar.gz
500500
GOLANGCI_LINT_EXEC_NAME = golangci-lint

hack/sort-imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def make_gci_commandline(tree, ciconfig=".golangci.yml"):
1111
with open(ciconfig) as src:
1212
cfg = yaml.safe_load(src)
1313
try:
14-
sections = cfg['linters-settings']['gci']['sections']
14+
sections = cfg['formatters']['settings']['gci']['sections']
1515
except KeyError:
1616
sys.stderr.write("cannot find gci configuration on %s\n" % ciconfig)
1717
sys.exit(2)

internal/schedcache/synced.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ func HasSynced(env *Env, nodeNames []string) (bool, map[string]sets.Set[string],
7878

7979
unsynced := make(map[string]sets.Set[string])
8080

81-
//nolint: ineffassign,staticcheck,wastedassign
8281
podList, err := podlist.With(env.Cli).ByDeployment(env.Ctx, *dp)
82+
if err != nil {
83+
return false, nil, err
84+
}
85+
8386
for idx := range podList {
8487
pod := &podList[idx]
8588

0 commit comments

Comments
 (0)