Skip to content

Commit 4c553ca

Browse files
committed
chore: Migrate to golangci-lint v2
1 parent b528c28 commit 4c553ca

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
E2E_SETUP_KUBECTL: yes
2222
SUDO: sudo
2323
GO_VERSION: "^1.24"
24-
GOLANGCI_LINT_VERSION: "v1.64.6"
24+
GOLANGCI_LINT_VERSION: "v2.0.2"
2525

2626
jobs:
2727
ci-go-lint:

.golangci.yml

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
enable:
75
- gocritic
86
- gocyclo
9-
- gofmt
10-
- goimports
117
- gosec
12-
- gosimple
138
- govet
149
- ineffassign
1510
- misspell
@@ -18,22 +13,34 @@ linters:
1813
- staticcheck
1914
- unconvert
2015
- unused
21-
22-
linters-settings:
23-
goimports:
24-
local-prefixes: k8s.io/kube-state-metrics,k8s.io/kube-state-metrics/v2
25-
26-
issues:
27-
exclude-use-default: false
28-
exclude-rules:
29-
# We don't check metrics naming in the tests.
30-
- path: _test\.go
31-
linters:
32-
- promlinter
33-
# TODO(mrueg) Improve error handling
34-
- text: "G104:"
35-
linters:
36-
- gosec
37-
- text: "package-comments:"
38-
linters:
39-
- revive
16+
exclusions:
17+
generated: lax
18+
rules:
19+
- linters:
20+
- promlinter
21+
path: _test\.go
22+
- linters:
23+
- gosec
24+
text: 'G104:'
25+
- linters:
26+
- revive
27+
text: 'package-comments:'
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports
36+
settings:
37+
goimports:
38+
local-prefixes:
39+
- k8s.io/kube-state-metrics
40+
- k8s.io/kube-state-metrics/v2
41+
exclusions:
42+
generated: lax
43+
paths:
44+
- third_party$
45+
- builtin$
46+
- examples$

pkg/sharding/listwatch_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestSharding(t *testing.T) {
4242
totalShards: 2,
4343
}
4444

45-
if !(s1.keep(cm) || s2.keep(cm)) {
45+
if !s1.keep(cm) && !s2.keep(cm) {
4646
t.Fatal("One shard must pick up the object.")
4747
}
4848

tests/e2e/framework/framework.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (k *KSMClient) IsHealthz() (bool, error) {
118118

119119
func (k *KSMClient) writeMetrics(endpoint *url.URL, w io.Writer) error {
120120
if endpoint == nil {
121-
return errors.New("Endpoint is nil")
121+
return errors.New("endpoint is nil")
122122
}
123123

124124
u := *endpoint
@@ -165,7 +165,7 @@ func (f *Framework) ParseMetrics(metrics func(io.Writer) error) (map[string]*dto
165165
buf := &bytes.Buffer{}
166166
err := metrics(buf)
167167
if err != nil {
168-
return nil, fmt.Errorf("Failed to get metrics: %w", err)
168+
return nil, fmt.Errorf("failed to get metrics: %w", err)
169169
}
170170

171171
parser := &expfmt.TextParser{}

0 commit comments

Comments
 (0)