Skip to content

Commit 114275c

Browse files
authored
Remove deprecated linter and fix issues (#2433)
1 parent 82e7591 commit 114275c

20 files changed

+6
-34
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ linters:
5353
enable:
5454
- asasalint
5555
- asciicheck
56+
- copyloopvar
5657
- dupword
5758
- errcheck
5859
- errname
5960
- errorlint
60-
- exportloopref
6161
- fatcontext
6262
- ginkgolinter
6363
- gocheckcompilerdirectives

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
- javascript
4242

4343
- repo: https://github.com/golangci/golangci-lint
44-
rev: v1.59.1
44+
rev: v1.60.2
4545
hooks:
4646
- id: golangci-lint-full
4747
name: golangci-lint-root

cmd/gateway/commands_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ func TestCommonFlagsValidation(t *testing.T) {
133133
}
134134

135135
for _, test := range tests {
136-
test := test
137136
t.Run(test.name+"_static_mode", func(t *testing.T) {
138137
t.Parallel()
139138
testFlag(t, createStaticModeCommand(), test)
@@ -387,7 +386,6 @@ func TestStaticModeCmdFlagValidation(t *testing.T) {
387386
// common flags validation is tested separately
388387

389388
for _, test := range tests {
390-
test := test
391389
t.Run(test.name, func(t *testing.T) {
392390
t.Parallel()
393391
cmd := createStaticModeCommand()
@@ -461,7 +459,6 @@ func TestSleepCmdFlagValidation(t *testing.T) {
461459
}
462460

463461
for _, test := range tests {
464-
test := test
465462
t.Run(test.name, func(t *testing.T) {
466463
t.Parallel()
467464
cmd := createSleepCommand()

cmd/gateway/validation_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func TestValidateGatewayControllerName(t *testing.T) {
5252
}
5353

5454
for _, test := range tests {
55-
test := test
5655
t.Run(test.name, func(t *testing.T) {
5756
t.Parallel()
5857
g := NewWithT(t)
@@ -118,7 +117,6 @@ func TestValidateResourceName(t *testing.T) {
118117
}
119118

120119
for _, test := range tests {
121-
test := test
122120
t.Run(test.name, func(t *testing.T) {
123121
t.Parallel()
124122
g := NewWithT(t)
@@ -184,7 +182,6 @@ func TestValidateNamespaceName(t *testing.T) {
184182
}
185183

186184
for _, test := range tests {
187-
test := test
188185
t.Run(test.name, func(t *testing.T) {
189186
t.Parallel()
190187
g := NewWithT(t)
@@ -249,7 +246,6 @@ func TestParseNamespacedResourceName(t *testing.T) {
249246
}
250247

251248
for _, test := range tests {
252-
test := test
253249
t.Run(test.name, func(t *testing.T) {
254250
t.Parallel()
255251
g := NewWithT(t)
@@ -317,7 +313,6 @@ func TestValidateQualifiedName(t *testing.T) {
317313
}
318314

319315
for _, test := range tests {
320-
test := test
321316
t.Run(test.name, func(t *testing.T) {
322317
t.Parallel()
323318
g := NewWithT(t)
@@ -382,7 +377,6 @@ func TestValidateURL(t *testing.T) {
382377
}
383378

384379
for _, tc := range tests {
385-
tc := tc
386380
t.Run(tc.name, func(t *testing.T) {
387381
t.Parallel()
388382
g := NewWithT(t)
@@ -425,7 +419,6 @@ func TestValidateIP(t *testing.T) {
425419
}
426420

427421
for _, tc := range tests {
428-
tc := tc
429422
t.Run(tc.name, func(t *testing.T) {
430423
t.Parallel()
431424
g := NewWithT(t)
@@ -495,7 +488,6 @@ func TestValidateEndpoint(t *testing.T) {
495488
}
496489

497490
for _, tc := range tests {
498-
tc := tc
499491
t.Run(tc.name, func(t *testing.T) {
500492
t.Parallel()
501493
g := NewWithT(t)
@@ -535,7 +527,6 @@ func TestValidatePort(t *testing.T) {
535527
}
536528

537529
for _, tc := range tests {
538-
tc := tc
539530
t.Run(tc.name, func(t *testing.T) {
540531
t.Parallel()
541532
g := NewWithT(t)

internal/framework/controller/filter/filter_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func TestCreateSingleResourceFilter(t *testing.T) {
5151
}
5252

5353
for _, test := range tests {
54-
test := test
5554
t.Run(test.name, func(t *testing.T) {
5655
t.Parallel()
5756
g := NewWithT(t)

internal/framework/controller/index/endpointslice_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func TestServiceNameIndexFunc(t *testing.T) {
4343
}
4444

4545
for _, tc := range testcases {
46-
tc := tc
4746
t.Run(tc.msg, func(t *testing.T) {
4847
t.Parallel()
4948
g := NewWithT(t)

internal/framework/controller/predicate/annotation_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func TestAnnotationPredicate_Create(t *testing.T) {
5959
p := AnnotationPredicate{Annotation: annotation}
6060

6161
for _, test := range tests {
62-
test := test
6362
t.Run(test.name, func(t *testing.T) {
6463
t.Parallel()
6564
g := NewWithT(t)
@@ -215,7 +214,6 @@ func TestAnnotationPredicate_Update(t *testing.T) {
215214
p := AnnotationPredicate{Annotation: annotation}
216215

217216
for _, test := range tests {
218-
test := test
219217
t.Run(test.name, func(t *testing.T) {
220218
t.Parallel()
221219
g := NewWithT(t)

internal/framework/controller/predicate/service_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) {
228228
p := ServicePortsChangedPredicate{}
229229

230230
for _, tc := range testcases {
231-
tc := tc
232231
t.Run(tc.msg, func(t *testing.T) {
233232
t.Parallel()
234233
g := NewWithT(t)
@@ -445,7 +444,6 @@ func TestGatewayServicePredicate_Update(t *testing.T) {
445444
p := GatewayServicePredicate{NSName: types.NamespacedName{Namespace: "nginx-gateway", Name: "nginx"}}
446445

447446
for _, tc := range testcases {
448-
tc := tc
449447
t.Run(tc.msg, func(t *testing.T) {
450448
t.Parallel()
451449
g := NewWithT(t)

internal/framework/controller/register_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func TestRegister(t *testing.T) {
121121
}
122122

123123
for _, test := range tests {
124-
test := test
125124
t.Run(test.msg, func(t *testing.T) {
126125
t.Parallel()
127126
g := NewWithT(t)

internal/framework/gatewayclass/validate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ func TestValidateCRDVersions(t *testing.T) {
114114
}
115115

116116
for _, test := range tests {
117-
test := test
118117
t.Run(test.name, func(t *testing.T) {
119118
t.Parallel()
120119
g := NewWithT(t)

internal/framework/helpers/helpers_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func TestEqualPointers(t *testing.T) {
8080
}
8181

8282
for _, test := range tests {
83-
test := test
8483
t.Run(test.name, func(t *testing.T) {
8584
t.Parallel()
8685
g := NewWithT(t)

internal/framework/status/conditions_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ func TestConditionsEqual(t *testing.T) {
111111
}
112112

113113
for _, test := range tests {
114-
test := test
115114
t.Run(test.name, func(t *testing.T) {
116115
t.Parallel()
117116
g := NewWithT(t)

internal/framework/status/updater_retry_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func TestNewRetryUpdateFunc(t *testing.T) {
7171
}
7272

7373
for _, test := range tests {
74-
test := test
7574
t.Run(test.name, func(t *testing.T) {
7675
t.Parallel()
7776
g := NewWithT(t)

internal/mode/static/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func StartManager(cfg config.Config) error {
113113

114114
// protectedPorts is the map of ports that may not be configured by a listener, and the name of what it is used for
115115
protectedPorts := map[int32]string{
116-
int32(cfg.MetricsConfig.Port): "MetricsPort",
117-
int32(cfg.HealthConfig.Port): "HealthPort",
116+
int32(cfg.MetricsConfig.Port): "MetricsPort", //nolint:gosec // port will not overflow int32
117+
int32(cfg.HealthConfig.Port): "HealthPort", //nolint:gosec // port will not overflow int32
118118
}
119119

120120
mustExtractGVK := kinds.NewMustExtractGKV(scheme)

internal/mode/static/state/graph/gateway_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func TestBuildGateway(t *testing.T) {
239239
return v1.Listener{
240240
Name: v1.SectionName(name),
241241
Hostname: (*v1.Hostname)(helpers.GetPointer(hostname)),
242-
Port: v1.PortNumber(port),
242+
Port: v1.PortNumber(port), //nolint:gosec // port number will not overflow int32
243243
Protocol: protocol,
244244
TLS: tls,
245245
}

internal/mode/static/state/graph/reference_grant_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func TestReferenceGrantResolver(t *testing.T) {
162162
resolver := newReferenceGrantResolver(refGrants)
163163

164164
for _, test := range tests {
165-
test := test
166165
t.Run(test.msg, func(t *testing.T) {
167166
t.Parallel()
168167

@@ -415,7 +414,6 @@ func TestRefAllowedFrom(t *testing.T) {
415414
}
416415

417416
for _, test := range tests {
418-
test := test
419417
t.Run(test.name, func(t *testing.T) {
420418
t.Parallel()
421419

internal/mode/static/state/graph/tlsroute_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ func TestBuildTLSRoute(t *testing.T) {
551551
}
552552

553553
for _, test := range tests {
554-
test := test
555554
t.Run(test.name, func(t *testing.T) {
556555
g := NewWithT(t)
557556
t.Parallel()

internal/mode/static/status/prepare_requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func prepareGatewayRequest(
284284
listenerStatuses = append(listenerStatuses, v1.ListenerStatus{
285285
Name: v1.SectionName(l.Name),
286286
SupportedKinds: l.SupportedKinds,
287-
AttachedRoutes: int32(len(l.Routes)) + int32(len(l.L4Routes)),
287+
AttachedRoutes: int32(len(l.Routes)) + int32(len(l.L4Routes)), //nolint:gosec // num routes will not overflow
288288
Conditions: apiConds,
289289
})
290290
}

tests/suite/scale_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ var _ = Describe("Zero downtime scale test", Ordered, Label("nfr", "zero-downtim
736736
buf := new(bytes.Buffer)
737737
encoder := framework.NewVegetaCSVEncoder(buf)
738738
for _, res := range results {
739-
res := res
740739
Expect(encoder.Encode(&res)).To(Succeed())
741740
}
742741

tests/suite/upgrade_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() {
162162
buf := new(bytes.Buffer)
163163
encoder := framework.NewVegetaCSVEncoder(buf)
164164
for _, res := range results {
165-
res := res
166165
Expect(encoder.Encode(&res)).To(Succeed())
167166
}
168167

0 commit comments

Comments
 (0)