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

+2-1
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

-6
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

-1
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

-4
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

-8
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

-9
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

-1
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

-6
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

-1
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

-1
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{}

github/pulls_reviews_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ func TestPullRequestReviewRequest_isComfortFadePreview(t *testing.T) {
330330
}}
331331

332332
for _, tc := range tests {
333-
tc := tc
334333
t.Run(tc.name, func(t *testing.T) {
335334
t.Parallel()
336335
gotBool, gotErr := tc.review.isComfortFadePreview()

github/repos_commits_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ func TestRepositoriesService_CompareCommits(t *testing.T) {
384384
}
385385

386386
for i, sample := range testCases {
387-
sample := sample
388387
t.Run(fmt.Sprintf("case #%v", i+1), func(t *testing.T) {
389388
t.Parallel()
390389
client, mux, _ := setup(t)
@@ -526,7 +525,6 @@ func TestRepositoriesService_CompareCommitsRaw_diff(t *testing.T) {
526525
}
527526

528527
for i, sample := range testCases {
529-
sample := sample
530528
t.Run(fmt.Sprintf("case #%v", i+1), func(t *testing.T) {
531529
t.Parallel()
532530
client, mux, _ := setup(t)
@@ -585,7 +583,6 @@ func TestRepositoriesService_CompareCommitsRaw_patch(t *testing.T) {
585583
}
586584

587585
for i, sample := range testCases {
588-
sample := sample
589586
t.Run(fmt.Sprintf("case #%v", i+1), func(t *testing.T) {
590587
t.Parallel()
591588
client, mux, _ := setup(t)
@@ -632,7 +629,6 @@ func TestRepositoriesService_CompareCommitsRaw_invalid(t *testing.T) {
632629
}
633630

634631
for i, sample := range testCases {
635-
sample := sample
636632
t.Run(fmt.Sprintf("case #%v", i+1), func(t *testing.T) {
637633
t.Parallel()
638634
client, _, _ := setup(t)

github/repos_contents_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) {
722722
}
723723

724724
for _, tc := range tcs {
725-
tc := tc
726725
t.Run(tc.name, func(t *testing.T) {
727726
t.Parallel()
728727
client, mux, _ := setup(t)
@@ -780,7 +779,6 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_dontFollowRed
780779
}
781780

782781
for _, tc := range tcs {
783-
tc := tc
784782
t.Run(tc.name, func(t *testing.T) {
785783
t.Parallel()
786784
client, mux, _ := setup(t)
@@ -816,7 +814,6 @@ func TestRepositoriesService_GetArchiveLink_StatusMovedPermanently_followRedirec
816814
}
817815

818816
for _, tc := range tcs {
819-
tc := tc
820817
t.Run(tc.name, func(t *testing.T) {
821818
t.Parallel()
822819
client, mux, serverURL := setup(t)

github/repos_environments_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func TestRequiredReviewer_UnmarshalJSON(t *testing.T) {
7070
}
7171

7272
for name, test := range testCases {
73-
test := test
7473
t.Run(name, func(t *testing.T) {
7574
t.Parallel()
7675
rule := []*RequiredReviewer{}

github/repos_hooks_deliveries_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ var hookDeliveryPayloadTypeToStruct = map[string]interface{}{
205205
func TestHookDelivery_ParsePayload(t *testing.T) {
206206
t.Parallel()
207207
for evt, obj := range hookDeliveryPayloadTypeToStruct {
208-
evt, obj := evt, obj
209208
t.Run(evt, func(t *testing.T) {
210209
t.Parallel()
211210
bs, err := json.Marshal(obj)

0 commit comments

Comments
 (0)