Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfae30a0

Browse files
authored
chore: remove unnecessary redeclarations in for loops (#18440)
1 parent4fe0a4b commitfae30a0

File tree

200 files changed

+0
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+0
-431
lines changed

‎agent/agent_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func TestAgent_Stats_SSH(t *testing.T) {
130130
t.Parallel()
131131

132132
for_,port:=rangesshPorts {
133-
port:=port
134133
t.Run(fmt.Sprintf("(:%d)",port),func(t*testing.T) {
135134
t.Parallel()
136135

@@ -342,7 +341,6 @@ func TestAgent_SessionExec(t *testing.T) {
342341
t.Parallel()
343342

344343
for_,port:=rangesshPorts {
345-
port:=port
346344
t.Run(fmt.Sprintf("(:%d)",port),func(t*testing.T) {
347345
t.Parallel()
348346

@@ -468,7 +466,6 @@ func TestAgent_SessionTTYShell(t *testing.T) {
468466
}
469467

470468
for_,port:=rangesshPorts {
471-
port:=port
472469
t.Run(fmt.Sprintf("(%d)",port),func(t*testing.T) {
473470
t.Parallel()
474471

@@ -611,7 +608,6 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) {
611608
}
612609

613610
for_,test:=rangetests {
614-
test:=test
615611
t.Run(test.name,func(t*testing.T) {
616612
t.Parallel()
617613
session:=setupSSHSession(t,test.manifest,test.banner,func(fs afero.Fs) {
@@ -688,16 +684,13 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
688684

689685
//nolint:paralleltest // These tests need to swap the banner func.
690686
for_,port:=rangesshPorts {
691-
port:=port
692-
693687
sshClient,err:=conn.SSHClientOnPort(ctx,port)
694688
require.NoError(t,err)
695689
t.Cleanup(func() {
696690
_=sshClient.Close()
697691
})
698692

699693
fori,test:=rangetests {
700-
test:=test
701694
t.Run(fmt.Sprintf("(:%d)/%d",port,i),func(t*testing.T) {
702695
// Set new banner func and wait for the agent to call it to update the
703696
// banner.
@@ -1210,7 +1203,6 @@ func TestAgent_CoderEnvVars(t *testing.T) {
12101203
t.Parallel()
12111204

12121205
for_,key:=range []string{"CODER","CODER_WORKSPACE_NAME","CODER_WORKSPACE_OWNER_NAME","CODER_WORKSPACE_AGENT_NAME"} {
1213-
key:=key
12141206
t.Run(key,func(t*testing.T) {
12151207
t.Parallel()
12161208

@@ -1233,7 +1225,6 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) {
12331225
// For some reason this test produces a TTY locally and a non-TTY in CI
12341226
// so we don't test for the absence of SSH_TTY.
12351227
for_,key:=range []string{"SSH_CONNECTION","SSH_CLIENT"} {
1236-
key:=key
12371228
t.Run(key,func(t*testing.T) {
12381229
t.Parallel()
12391230

@@ -1276,7 +1267,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) {
12761267
},
12771268
}
12781269
for_,tt:=rangetests {
1279-
tt:=tt
12801270
t.Run(tt.key,func(t*testing.T) {
12811271
t.Parallel()
12821272

@@ -1796,7 +1786,6 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
17961786
t.Setenv("LANG","C")
17971787

17981788
for_,backendType:=rangebackends {
1799-
backendType:=backendType
18001789
t.Run(backendType,func(t*testing.T) {
18011790
ifbackendType=="Screen" {
18021791
ifruntime.GOOS!="linux" {
@@ -2496,7 +2485,6 @@ func TestAgent_Dial(t *testing.T) {
24962485
}
24972486

24982487
for_,c:=rangecases {
2499-
c:=c
25002488
t.Run(c.name,func(t*testing.T) {
25012489
t.Parallel()
25022490

‎agent/agentcontainers/containers_internal_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func TestWrapDockerExec(t *testing.T) {
4141
},
4242
}
4343
for_,tt:=rangetests {
44-
tt:=tt// appease the linter even though this isn't needed anymore
4544
t.Run(tt.name,func(t*testing.T) {
4645
t.Parallel()
4746
actualCmd,actualArgs:=wrapDockerExec("my-container",tt.containerUser,tt.cmdArgs[0],tt.cmdArgs[1:]...)
@@ -54,7 +53,6 @@ func TestWrapDockerExec(t *testing.T) {
5453
funcTestConvertDockerPort(t*testing.T) {
5554
t.Parallel()
5655

57-
//nolint:paralleltest // variable recapture no longer required
5856
for_,tc:=range []struct {
5957
namestring
6058
instring
@@ -101,7 +99,6 @@ func TestConvertDockerPort(t *testing.T) {
10199
expectError:"invalid port",
102100
},
103101
} {
104-
//nolint: paralleltest // variable recapture no longer required
105102
t.Run(tc.name,func(t*testing.T) {
106103
t.Parallel()
107104
actualPort,actualNetwork,actualErr:=convertDockerPort(tc.in)
@@ -151,7 +148,6 @@ func TestConvertDockerVolume(t *testing.T) {
151148
expectError:"invalid volume",
152149
},
153150
} {
154-
tc:=tc
155151
t.Run(tc.name,func(t*testing.T) {
156152
t.Parallel()
157153
})

‎agent/agentssh/x11_internal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ func Test_addXauthEntry(t *testing.T) {
228228
require.NoError(t,err)
229229

230230
for_,tt:=rangetests {
231-
tt:=tt
232231
t.Run(tt.name,func(t*testing.T) {
233232
t.Parallel()
234233

‎agent/proto/compare_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func TestLabelsEqual(t *testing.T) {
6767
eq:false,
6868
},
6969
} {
70-
tc:=tc
7170
t.Run(tc.name,func(t*testing.T) {
7271
t.Parallel()
7372
require.Equal(t,tc.eq,proto.LabelsEqual(tc.a,tc.b))

‎agent/proto/resourcesmonitor/queue_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) {
6565
}
6666

6767
for_,tt:=rangetests {
68-
tt:=tt
69-
7068
t.Run(tt.name,func(t*testing.T) {
7169
t.Parallel()
7270
queue:=resourcesmonitor.NewQueue(20)

‎agent/proto/resourcesmonitor/resources_monitor_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) {
195195
}
196196

197197
for_,tt:=rangetests {
198-
tt:=tt
199198
t.Run(tt.name,func(t*testing.T) {
200199
t.Parallel()
201200

‎apiversion/apiversion_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func TestAPIVersionValidate(t *testing.T) {
7272
expectedError:"no longer supported",
7373
},
7474
} {
75-
tc:=tc
7675
t.Run(tc.name,func(t*testing.T) {
7776
t.Parallel()
7877

‎buildinfo/buildinfo_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func TestBuildInfo(t *testing.T) {
9393
}
9494

9595
for_,c:=rangecases {
96-
c:=c
9796
t.Run(c.name,func(t*testing.T) {
9897
t.Parallel()
9998
require.Equal(t,c.expectMatch,buildinfo.VersionsMatch(c.v1,c.v2),

‎cli/agent_internal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func Test_extractPort(t *testing.T) {
5454
},
5555
}
5656
for_,tt:=rangetests {
57-
tt:=tt
5857
t.Run(tt.name,func(t*testing.T) {
5958
t.Parallel()
6059
got,err:=extractPort(tt.urlString)

‎cli/autoupdate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func TestAutoUpdate(t *testing.T) {
6262
}
6363

6464
for_,c:=rangecases {
65-
c:=c
6665
t.Run(c.Name,func(t*testing.T) {
6766
t.Parallel()
6867
client:=coderdtest.New(t,nil)

‎cli/clitest/golden.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ ExtractCommandPathsLoop:
7171
}
7272

7373
for_,tt:=rangecases {
74-
tt:=tt
7574
t.Run(tt.Name,func(t*testing.T) {
7675
t.Parallel()
7776
ctx:=testutil.Context(t,testutil.WaitLong)

‎cli/cliui/agent_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ func TestAgent(t *testing.T) {
369369
wantErr:true,
370370
},
371371
} {
372-
tc:=tc
373372
t.Run(tc.name,func(t*testing.T) {
374373
t.Parallel()
375374

@@ -648,7 +647,6 @@ func TestPeerDiagnostics(t *testing.T) {
648647
},
649648
}
650649
for_,tc:=rangetestCases {
651-
tc:=tc
652650
t.Run(tc.name,func(t*testing.T) {
653651
t.Parallel()
654652
r,w:=io.Pipe()
@@ -852,7 +850,6 @@ func TestConnDiagnostics(t *testing.T) {
852850
},
853851
}
854852
for_,tc:=rangetestCases {
855-
tc:=tc
856853
t.Run(tc.name,func(t*testing.T) {
857854
t.Parallel()
858855
r,w:=io.Pipe()

‎cli/cliui/provisionerjob_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ func TestProvisionerJob(t *testing.T) {
124124
}
125125

126126
for_,tc:=rangetests {
127-
tc:=tc
128-
129127
t.Run(tc.name,func(t*testing.T) {
130128
t.Parallel()
131129

‎cli/cliui/resources_internal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func TestRenderAgentVersion(t *testing.T) {
4040
},
4141
}
4242
for_,testCase:=rangetestCases {
43-
testCase:=testCase
4443
t.Run(testCase.name,func(t*testing.T) {
4544
t.Parallel()
4645
actual:=renderAgentVersion(testCase.agentVersion,testCase.serverVersion)

‎cli/cliui/table_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ foo <nil> 10 [a, b, c] foo1 11 foo2 12 fo
169169
// Test with pointer values.
170170
inPtr:=make([]*tableTest1,len(in))
171171
fori,v:=rangein {
172-
v:=v
173172
inPtr[i]=&v
174173
}
175174
out,err=cliui.DisplayTable(inPtr,"",nil)

‎cli/cliutil/levenshtein/levenshtein_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func Test_Levenshtein_Matches(t *testing.T) {
9595
Expected: []string{"kubernetes"},
9696
},
9797
} {
98-
tt:=tt
9998
t.Run(tt.Name,func(t*testing.T) {
10099
t.Parallel()
101100
actual:=levenshtein.Matches(tt.Needle,tt.MaxDistance,tt.Haystack...)
@@ -179,7 +178,6 @@ func Test_Levenshtein_Distance(t *testing.T) {
179178
Error:levenshtein.ErrMaxDist.Error(),
180179
},
181180
} {
182-
tt:=tt
183181
t.Run(tt.Name,func(t*testing.T) {
184182
t.Parallel()
185183
actual,err:=levenshtein.Distance(tt.A,tt.B,tt.MaxDist)

‎cli/cliutil/provisionerwarn_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func TestWarnMatchedProvisioners(t *testing.T) {
5959
},
6060
},
6161
} {
62-
tt:=tt
6362
t.Run(tt.name,func(t*testing.T) {
6463
t.Parallel()
6564
varw strings.Builder

‎cli/configssh_internal_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) {
118118
}
119119

120120
for_,tc:=rangetestCases {
121-
tc:=tc
122121
t.Run(tc.Name,func(t*testing.T) {
123122
t.Parallel()
124123

@@ -157,7 +156,6 @@ func Test_sshConfigProxyCommandEscape(t *testing.T) {
157156
}
158157
// nolint:paralleltest // Fixes a flake
159158
for_,tt:=rangetests {
160-
tt:=tt
161159
t.Run(tt.name,func(t*testing.T) {
162160
ifruntime.GOOS=="windows" {
163161
t.Skip("Windows doesn't typically execute via /bin/sh or cmd.exe, so this test is not applicable.")
@@ -207,7 +205,6 @@ func Test_sshConfigMatchExecEscape(t *testing.T) {
207205
}
208206
// nolint:paralleltest // Fixes a flake
209207
for_,tt:=rangetests {
210-
tt:=tt
211208
t.Run(tt.name,func(t*testing.T) {
212209
cmd:="/bin/sh"
213210
arg:="-c"
@@ -290,7 +287,6 @@ func Test_sshConfigExecEscapeSeparatorForce(t *testing.T) {
290287
},
291288
}
292289
for_,tt:=rangetests {
293-
tt:=tt
294290
t.Run(tt.name,func(t*testing.T) {
295291
t.Parallel()
296292
found,err:=sshConfigProxyCommandEscape(tt.path,tt.forceUnix)
@@ -366,7 +362,6 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
366362
}
367363

368364
for_,tt:=rangetestCases {
369-
tt:=tt
370365
t.Run(tt.Name,func(t*testing.T) {
371366
t.Parallel()
372367

‎cli/configssh_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
688688
},
689689
}
690690
for_,tt:=rangetests {
691-
tt:=tt
692691
t.Run(tt.name,func(t*testing.T) {
693692
t.Parallel()
694693

‎cli/exp_errors_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ ExtractCommandPathsLoop:
4949
}
5050

5151
for_,tt:=rangecases {
52-
tt:=tt
5352
t.Run(tt.Name,func(t*testing.T) {
5453
t.Parallel()
5554

‎cli/gitauth/askpass_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func TestParse(t *testing.T) {
6060
wantHost:"http://wow.io",
6161
},
6262
} {
63-
tc:=tc
6463
t.Run(tc.in,func(t*testing.T) {
6564
t.Parallel()
6665
user,host,err:=gitauth.ParseAskpass(tc.in)

‎cli/notifications_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func TestNotifications(t *testing.T) {
4848
}
4949

5050
for_,tt:=rangetests {
51-
tt:=tt
5251
t.Run(tt.name,func(t*testing.T) {
5352
t.Parallel()
5453

‎cli/open_internal_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func Test_resolveAgentAbsPath(t *testing.T) {
4747
{"fail with no working directory and rel path on windows",args{relOrAbsPath:"my\\path",agentOS:"windows"},"",true},
4848
}
4949
for_,tt:=rangetests {
50-
tt:=tt
5150
t.Run(tt.name,func(t*testing.T) {
5251
t.Parallel()
5352

@@ -156,7 +155,6 @@ func Test_buildAppLinkURL(t *testing.T) {
156155
expectedLink:"https://coder.tld/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/",
157156
},
158157
} {
159-
tt:=tt
160158
t.Run(tt.name,func(t*testing.T) {
161159
t.Parallel()
162160
baseURL,err:=url.Parse(tt.baseURL)

‎cli/open_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ func TestOpenVSCode(t *testing.T) {
113113
}
114114

115115
for_,tt:=rangetests {
116-
tt:=tt
117116
t.Run(tt.name,func(t*testing.T) {
118117
t.Parallel()
119118

@@ -240,7 +239,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
240239
}
241240

242241
for_,tt:=rangetests {
243-
tt:=tt
244242
t.Run(tt.name,func(t*testing.T) {
245243
t.Parallel()
246244

@@ -414,8 +412,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
414412
}
415413

416414
for_,tt:=rangetests {
417-
tt:=tt
418-
419415
t.Run(tt.name,func(t*testing.T) {
420416
t.Parallel()
421417

@@ -579,8 +575,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
579575
}
580576

581577
for_,tt:=rangetests {
582-
tt:=tt
583-
584578
t.Run(tt.name,func(t*testing.T) {
585579
t.Parallel()
586580

‎cli/portforward_internal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func Test_parsePortForwards(t *testing.T) {
103103
},
104104
}
105105
for_,tt:=rangetests {
106-
tt:=tt
107106
t.Run(tt.name,func(t*testing.T) {
108107
t.Parallel()
109108

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp