Skip to content

Commit 8986a34

Browse files
authored
chore(lint): update golangci-lint to v2.0.2 (#941)
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 89da4eb commit 8986a34

File tree

8 files changed

+188
-149
lines changed

8 files changed

+188
-149
lines changed

.golangci.yml

+90-71
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,13 @@
1-
run:
2-
timeout: 5m
3-
go: "1.22"
4-
5-
issues:
6-
exclude-use-default: false
7-
8-
linters-settings:
9-
govet:
10-
enable-all: true
11-
disable:
12-
- shadow
13-
- fieldalignment
14-
settings:
15-
printf: # analyzer name, run `go tool vet help` to see all analyzers
16-
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
17-
- Print
18-
- Printf
19-
- Println
20-
- Debug
21-
- Debugf
22-
- Info
23-
- Infof
24-
- Warn
25-
- Warnf
26-
- Error
27-
- Errorf
28-
gocritic:
29-
enabled-tags:
30-
- diagnostic
31-
- experimental
32-
- opinionated
33-
- performance
34-
- style
35-
disabled-checks:
36-
- dupImport # https://github.com/go-critic/go-critic/issues/845
37-
- commentFormatting
38-
- octalLiteral
39-
- unnamedResult
40-
- unnecessaryDefer
41-
- importShadow
42-
- emptyStringTest
43-
- hugeParam
44-
- rangeValCopy
45-
gosec:
46-
excludes:
47-
- G101
48-
gosimple:
49-
checks: ["all"]
50-
nolintlint:
51-
allow-unused: false # report any unused nolint directives
52-
require-explanation: false # don't require an explanation for nolint directives
53-
require-specific: true # require nolint directives to be specific about which linter is being skipped
54-
revive:
55-
confidence: 0
56-
# Due to https://github.com/golangci/golangci-lint/issues/2355 on MacOS the linter is failing with the error
57-
# message too many files. Set the max-open-files explicitly.
58-
max-open-files: 2048
59-
staticcheck:
60-
checks: ["all"]
61-
stylecheck:
62-
checks: ["all", "-ST1000"]
63-
testifylint:
64-
disable:
65-
- require-error
66-
enable-all: true
1+
formatters:
2+
enable:
3+
- gofmt
4+
- goimports
675

686
linters:
697
# please, do not use `enable-all`: it's deprecated and will be removed soon.
708
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
71-
disable-all: true
9+
default: none
10+
7211
enable:
7312
- asciicheck
7413
# - bodyclose
@@ -87,12 +26,9 @@ linters:
8726
# - godot
8827
# - godox
8928
# - goerr113
90-
- gofmt
91-
- goimports
9229
# - gomnd
9330
# - goprintffuncname
9431
- gosec
95-
- gosimple
9632
- govet
9733
- ineffassign
9834
# - interfacer
@@ -108,7 +44,6 @@ linters:
10844
# - scopelint
10945
- staticcheck
11046
# - structcheck
111-
- stylecheck
11247
# - testpackage
11348
- testifylint
11449
# - typecheck
@@ -118,3 +53,87 @@ linters:
11853
# - varcheck
11954
# - whitespace
12055
# - wsl
56+
57+
settings:
58+
gocritic:
59+
disabled-checks:
60+
- dupImport # https://github.com/go-critic/go-critic/issues/845
61+
- commentFormatting
62+
- octalLiteral
63+
- unnamedResult
64+
- unnecessaryDefer
65+
- importShadow
66+
- emptyStringTest
67+
- hugeParam
68+
- rangeValCopy
69+
70+
enabled-tags:
71+
- diagnostic
72+
- experimental
73+
- opinionated
74+
- performance
75+
- style
76+
77+
gosec:
78+
excludes:
79+
- G101
80+
81+
govet:
82+
disable:
83+
- shadow
84+
- fieldalignment
85+
86+
enable-all: true
87+
88+
settings:
89+
printf: # analyzer name, run `go tool vet help` to see all analyzers
90+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
91+
- Print
92+
- Printf
93+
- Println
94+
- Debug
95+
- Debugf
96+
- Info
97+
- Infof
98+
- Warn
99+
- Warnf
100+
- Error
101+
- Errorf
102+
103+
nolintlint:
104+
# report any unused nolint directives
105+
allow-unused: false
106+
107+
# don't require an explanation for nolint directives
108+
require-explanation: false
109+
110+
# require nolint directives to be specific about which linter is being skipped
111+
require-specific: true
112+
113+
revive:
114+
confidence: 0
115+
116+
# Due to https://github.com/golangci/golangci-lint/issues/2355 on MacOS the linter is failing with the error
117+
# message too many files. Set the max-open-files explicitly.
118+
max-open-files: 2048
119+
120+
staticcheck:
121+
checks:
122+
- all
123+
- -ST1000
124+
125+
testifylint:
126+
disable:
127+
- require-error
128+
129+
enable-all: true
130+
131+
output:
132+
show-stats: false
133+
134+
run:
135+
go: "1.22"
136+
137+
timeout: 5m
138+
139+
version: "2"

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ GOLANGCILINT_BIN := $(GOBIN)/golangci-lint
3232
$(GOLANGCILINT_BIN): deps
3333
@echo "+ $@"
3434
cd tool-imports; \
35-
GOBIN=$(GOBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint
35+
GOBIN=$(GOBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint
3636

3737
GORELEASER_BIN := $(GOBIN)/goreleaser
3838
$(GORELEASER_BIN): deps

docs/custom_resource_template_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var CertLifetime = check.Template{
5353
return []diagnostic.Diagnostic{{Message: "Invalid certificate"}}
5454
}
5555

56-
if cert.Spec.Duration.Duration.Hours() > 8760 {
56+
if cert.Spec.Duration.Hours() > 8760 {
5757
return []diagnostic.Diagnostic{{Message: "Certificates with lifetimes longer than one year are not allowed"}}
5858
}
5959
return nil

pkg/templates/danglingingress/template.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func getSelectorsFromIngress(ingress *networkingV1.Ingress) map[serviceDescripto
5353
}
5454

5555
for _, r := range ingress.Spec.Rules {
56-
spec := r.IngressRuleValue.HTTP
56+
spec := r.HTTP
5757
if spec == nil {
5858
continue
5959
}
@@ -106,14 +106,14 @@ func init() {
106106

107107
for _, port := range service.Spec.Ports {
108108
desc := serviceDescriptor{
109-
name: service.ObjectMeta.Name,
109+
name: service.Name,
110110
port: intstr.FromInt(int(port.Port)),
111111
}
112112
delete(selectors, desc)
113113

114114
if port.Name != "" {
115115
desc := serviceDescriptor{
116-
name: service.ObjectMeta.Name,
116+
name: service.Name,
117117
port: intstr.FromString(port.Name),
118118
}
119119
delete(selectors, desc)

pkg/templates/util/check_probe_port.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ func CheckProbePort(container *v1.Container, probe *v1.Probe) []diagnostic.Diagn
2424
ports[intstr.FromString(port.Name)] = sentinel
2525
}
2626

27-
if httpProbe := probe.ProbeHandler.HTTPGet; httpProbe != nil {
27+
if httpProbe := probe.HTTPGet; httpProbe != nil {
2828
if _, ok := ports[httpProbe.Port]; !ok {
2929
return []diagnostic.Diagnostic{{
3030
Message: fmt.Sprintf("container %q does not expose port %s for the HTTPGet", container.Name, httpProbe.Port.String()),
3131
}}
3232
}
3333
}
3434

35-
if tcpProbe := probe.ProbeHandler.TCPSocket; tcpProbe != nil {
35+
if tcpProbe := probe.TCPSocket; tcpProbe != nil {
3636
if _, ok := ports[tcpProbe.Port]; !ok {
3737
return []diagnostic.Diagnostic{{
3838
Message: fmt.Sprintf("container %q does not expose port %s for the TCPSocket", container.Name, tcpProbe.Port.String()),
3939
}}
4040
}
4141
}
4242

43-
if grpcProbe := probe.ProbeHandler.GRPC; grpcProbe != nil {
43+
if grpcProbe := probe.GRPC; grpcProbe != nil {
4444
if _, ok := ports[intstr.FromInt32(grpcProbe.Port)]; !ok {
4545
return []diagnostic.Diagnostic{{
4646
Message: fmt.Sprintf("container %q does not expose port %d for the GRPC check", container.Name, grpcProbe.Port),

0 commit comments

Comments
 (0)