Skip to content

Commit 3a3f51b

Browse files
authored
chore: Remove redundant in Go 1.22 loop variables (#3537)
1 parent 6f329be commit 3a3f51b

19 files changed

+2
-93
lines changed

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ run:
55
linters:
66
enable:
77
- canonicalheader
8+
- copyloopvar
89
- dogsled
910
- dupl
1011
- gci
@@ -42,7 +43,7 @@ linters-settings:
4243
CopyrightDate: "Copyright \\d{4} "
4344
template: |-
4445
{{CopyrightDate}}The go-github AUTHORS. All rights reserved.
45-
46+
4647
Use of this source code is governed by a BSD-style
4748
license that can be found in the LICENSE file.
4849
gosec:

github/actions_artifacts_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ func TestActionsService_DownloadArtifact(t *testing.T) {
289289
}
290290

291291
for _, tc := range tcs {
292-
tc := tc
293292
t.Run(tc.name, func(t *testing.T) {
294293
t.Parallel()
295294
client, mux, _ := setup(t)
@@ -351,7 +350,6 @@ func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
351350
}
352351

353352
for _, tc := range tcs {
354-
tc := tc
355353
t.Run(tc.name, func(t *testing.T) {
356354
t.Parallel()
357355
client, _, _ := setup(t)
@@ -381,7 +379,6 @@ func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
381379
}
382380

383381
for _, tc := range tcs {
384-
tc := tc
385382
t.Run(tc.name, func(t *testing.T) {
386383
t.Parallel()
387384
client, _, _ := setup(t)
@@ -411,7 +408,6 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
411408
}
412409

413410
for _, tc := range tcs {
414-
tc := tc
415411
t.Run(tc.name, func(t *testing.T) {
416412
t.Parallel()
417413
client, mux, _ := setup(t)
@@ -448,7 +444,6 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
448444
}
449445

450446
for _, tc := range tcs {
451-
tc := tc
452447
t.Run(tc.name, func(t *testing.T) {
453448
t.Parallel()
454449
client, mux, serverURL := setup(t)
@@ -497,7 +492,6 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) {
497492
}
498493

499494
for _, tc := range tcs {
500-
tc := tc
501495
t.Run(tc.name, func(t *testing.T) {
502496
t.Parallel()
503497
client, mux, serverURL := setup(t)

github/actions_secrets_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) {
7676
}
7777

7878
for name, tt := range testCases {
79-
tt := tt
8079
t.Run(name, func(t *testing.T) {
8180
t.Parallel()
8281
pk := PublicKey{}

github/actions_workflow_jobs_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) {
200200
}
201201

202202
for _, tc := range tcs {
203-
tc := tc
204203
t.Run(tc.name, func(t *testing.T) {
205204
t.Parallel()
206205
client, mux, _ := setup(t)
@@ -261,7 +260,6 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_dontFollowRedi
261260
}
262261

263262
for _, tc := range tcs {
264-
tc := tc
265263
t.Run(tc.name, func(t *testing.T) {
266264
t.Parallel()
267265
client, mux, _ := setup(t)
@@ -298,7 +296,6 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_followRedirect
298296
}
299297

300298
for _, tc := range tcs {
301-
tc := tc
302299
t.Run(tc.name, func(t *testing.T) {
303300
t.Parallel()
304301
client, mux, serverURL := setup(t)
@@ -351,7 +348,6 @@ func TestActionsService_GetWorkflowJobLogs_unexpectedCode(t *testing.T) {
351348
}
352349

353350
for _, tc := range tcs {
354-
tc := tc
355351
t.Run(tc.name, func(t *testing.T) {
356352
t.Parallel()
357353
client, mux, serverURL := setup(t)

github/actions_workflow_runs_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ func TestActionsService_GetWorkflowRunAttemptLogs(t *testing.T) {
206206
}
207207

208208
for _, tc := range tcs {
209-
tc := tc
210209
t.Run(tc.name, func(t *testing.T) {
211210
t.Parallel()
212211
client, mux, _ := setup(t)
@@ -256,7 +255,6 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_dontFol
256255
}
257256

258257
for _, tc := range tcs {
259-
tc := tc
260258
t.Run(tc.name, func(t *testing.T) {
261259
t.Parallel()
262260
client, mux, _ := setup(t)
@@ -293,7 +291,6 @@ func TestActionsService_GetWorkflowRunAttemptLogs_StatusMovedPermanently_followR
293291
}
294292

295293
for _, tc := range tcs {
296-
tc := tc
297294
t.Run(tc.name, func(t *testing.T) {
298295
t.Parallel()
299296
client, mux, serverURL := setup(t)
@@ -352,7 +349,6 @@ func TestActionsService_GetWorkflowRunAttemptLogs_unexpectedCode(t *testing.T) {
352349
}
353350

354351
for _, tc := range tcs {
355-
tc := tc
356352
t.Run(tc.name, func(t *testing.T) {
357353
t.Parallel()
358354
client, mux, serverURL := setup(t)
@@ -521,7 +517,6 @@ func TestActionsService_GetWorkflowRunLogs(t *testing.T) {
521517
}
522518

523519
for _, tc := range tcs {
524-
tc := tc
525520
t.Run(tc.name, func(t *testing.T) {
526521
t.Parallel()
527522
client, mux, _ := setup(t)
@@ -571,7 +566,6 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_dontFollowRedi
571566
}
572567

573568
for _, tc := range tcs {
574-
tc := tc
575569
t.Run(tc.name, func(t *testing.T) {
576570
t.Parallel()
577571
client, mux, _ := setup(t)
@@ -608,7 +602,6 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirect
608602
}
609603

610604
for _, tc := range tcs {
611-
tc := tc
612605
t.Run(tc.name, func(t *testing.T) {
613606
t.Parallel()
614607
client, mux, serverURL := setup(t)
@@ -667,7 +660,6 @@ func TestActionsService_GetWorkflowRunLogs_unexpectedCode(t *testing.T) {
667660
}
668661

669662
for _, tc := range tcs {
670-
tc := tc
671663
t.Run(tc.name, func(t *testing.T) {
672664
t.Parallel()
673665
client, mux, serverURL := setup(t)

github/codespaces_secrets_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func TestCodespacesService_ListSecrets(t *testing.T) {
7777
}
7878

7979
for _, tt := range tests {
80-
tt := tt
8180
t.Run(tt.name, func(t *testing.T) {
8281
t.Parallel()
8382
client, mux, _ := setup(t)
@@ -177,7 +176,6 @@ func TestCodespacesService_GetSecret(t *testing.T) {
177176
}
178177

179178
for _, tt := range tests {
180-
tt := tt
181179
t.Run(tt.name, func(t *testing.T) {
182180
t.Parallel()
183181
client, mux, _ := setup(t)
@@ -277,7 +275,6 @@ func TestCodespacesService_CreateOrUpdateSecret(t *testing.T) {
277275
}
278276

279277
for _, tt := range tests {
280-
tt := tt
281278
t.Run(tt.name, func(t *testing.T) {
282279
t.Parallel()
283280
client, mux, _ := setup(t)
@@ -364,7 +361,6 @@ func TestCodespacesService_DeleteSecret(t *testing.T) {
364361
}
365362

366363
for _, tt := range tests {
367-
tt := tt
368364
t.Run(tt.name, func(t *testing.T) {
369365
t.Parallel()
370366
client, mux, _ := setup(t)
@@ -450,7 +446,6 @@ func TestCodespacesService_GetPublicKey(t *testing.T) {
450446
}
451447

452448
for _, tt := range tests {
453-
tt := tt
454449
t.Run(tt.name, func(t *testing.T) {
455450
t.Parallel()
456451
client, mux, _ := setup(t)
@@ -529,7 +524,6 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) {
529524
}
530525

531526
for _, tt := range tests {
532-
tt := tt
533527
t.Run(tt.name, func(t *testing.T) {
534528
t.Parallel()
535529
client, mux, _ := setup(t)
@@ -616,7 +610,6 @@ func TestCodespacesService_SetSelectedReposForSecret(t *testing.T) {
616610
}
617611

618612
for _, tt := range tests {
619-
tt := tt
620613
t.Run(tt.name, func(t *testing.T) {
621614
t.Parallel()
622615
client, mux, _ := setup(t)
@@ -684,7 +677,6 @@ func TestCodespacesService_AddSelectedReposForSecret(t *testing.T) {
684677
}
685678

686679
for _, tt := range tests {
687-
tt := tt
688680
t.Run(tt.name, func(t *testing.T) {
689681
t.Parallel()
690682
client, mux, _ := setup(t)
@@ -752,7 +744,6 @@ func TestCodespacesService_RemoveSelectedReposFromSecret(t *testing.T) {
752744
}
753745

754746
for _, tt := range tests {
755-
tt := tt
756747
t.Run(tt.name, func(t *testing.T) {
757748
t.Parallel()
758749
client, mux, _ := setup(t)

github/copilot_test.go

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

116116
for _, tc := range tests {
117-
tc := tc
118117
seatDetails := &CopilotSeatDetails{}
119118

120119
t.Run(tc.name, func(t *testing.T) {

github/github_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ func TestWithEnterpriseURLs(t *testing.T) {
485485
wantUploadURL: "https://cloud-api.custom-upload-url/api/uploads/",
486486
},
487487
} {
488-
test := test
489488
t.Run(test.name, func(t *testing.T) {
490489
t.Parallel()
491490
validate := func(c *Client, err error) {
@@ -2135,7 +2134,6 @@ func TestCompareHttpResponse(t *testing.T) {
21352134
}
21362135

21372136
for name, tc := range testcases {
2138-
tc := tc
21392137
t.Run(name, func(t *testing.T) {
21402138
t.Parallel()
21412139
v := compareHTTPResponse(tc.h1, tc.h2)
@@ -2294,7 +2292,6 @@ func TestErrorResponse_Is(t *testing.T) {
22942292
}
22952293

22962294
for name, tc := range testcases {
2297-
tc := tc
22982295
t.Run(name, func(t *testing.T) {
22992296
t.Parallel()
23002297
if tc.wantSame != err.Is(tc.otherError) {
@@ -2364,7 +2361,6 @@ func TestRateLimitError_Is(t *testing.T) {
23642361
}
23652362

23662363
for name, tc := range testcases {
2367-
tc := tc
23682364
t.Run(name, func(t *testing.T) {
23692365
t.Parallel()
23702366
if tc.wantSame != tc.err.Is(tc.otherError) {
@@ -2451,7 +2447,6 @@ func TestAbuseRateLimitError_Is(t *testing.T) {
24512447
}
24522448

24532449
for name, tc := range testcases {
2454-
tc := tc
24552450
t.Run(name, func(t *testing.T) {
24562451
t.Parallel()
24572452
if tc.wantSame != tc.err.Is(tc.otherError) {
@@ -2483,7 +2478,6 @@ func TestAcceptedError_Is(t *testing.T) {
24832478
}
24842479

24852480
for name, tc := range testcases {
2486-
tc := tc
24872481
t.Run(name, func(t *testing.T) {
24882482
t.Parallel()
24892483
if tc.wantSame != err.Is(tc.otherError) {

github/messages_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ func TestValidatePayload_BadRequestBody(t *testing.T) {
215215
}
216216

217217
for i, tt := range tests {
218-
tt := tt
219218
t.Run(fmt.Sprintf("test #%v", i), func(t *testing.T) {
220219
t.Parallel()
221220
req := &http.Request{

github/orgs_properties_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ func TestCustomPropertyValue_UnmarshalJSON(t *testing.T) {
423423
}
424424

425425
for name, tc := range tests {
426-
tc := tc
427426
t.Run(name, func(t *testing.T) {
428427
t.Parallel()
429428
cpv := &CustomPropertyValue{}

0 commit comments

Comments
 (0)