chore: remove unnecessary redeclarations in for loops (#18440)

This commit is contained in:
ケイラ
2025-06-20 13:16:55 -06:00
committed by GitHub
parent 4fe0a4bca2
commit fae30a00fd
200 changed files with 0 additions and 431 deletions
-1
View File
@@ -54,7 +54,6 @@ func Test_extractPort(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := extractPort(tt.urlString)
-1
View File
@@ -62,7 +62,6 @@ func TestAutoUpdate(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
-1
View File
@@ -71,7 +71,6 @@ ExtractCommandPathsLoop:
}
for _, tt := range cases {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
-3
View File
@@ -369,7 +369,6 @@ func TestAgent(t *testing.T) {
wantErr: true,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -648,7 +647,6 @@ func TestPeerDiagnostics(t *testing.T) {
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
r, w := io.Pipe()
@@ -852,7 +850,6 @@ func TestConnDiagnostics(t *testing.T) {
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
r, w := io.Pipe()
-2
View File
@@ -124,8 +124,6 @@ func TestProvisionerJob(t *testing.T) {
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -40,7 +40,6 @@ func TestRenderAgentVersion(t *testing.T) {
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion)
-1
View File
@@ -169,7 +169,6 @@ foo <nil> 10 [a, b, c] foo1 11 foo2 12 fo
// Test with pointer values.
inPtr := make([]*tableTest1, len(in))
for i, v := range in {
v := v
inPtr[i] = &v
}
out, err = cliui.DisplayTable(inPtr, "", nil)
@@ -95,7 +95,6 @@ func Test_Levenshtein_Matches(t *testing.T) {
Expected: []string{"kubernetes"},
},
} {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
actual := levenshtein.Matches(tt.Needle, tt.MaxDistance, tt.Haystack...)
@@ -179,7 +178,6 @@ func Test_Levenshtein_Distance(t *testing.T) {
Error: levenshtein.ErrMaxDist.Error(),
},
} {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
actual, err := levenshtein.Distance(tt.A, tt.B, tt.MaxDist)
-1
View File
@@ -59,7 +59,6 @@ func TestWarnMatchedProvisioners(t *testing.T) {
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var w strings.Builder
-5
View File
@@ -118,7 +118,6 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) {
}
for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
@@ -157,7 +156,6 @@ func Test_sshConfigProxyCommandEscape(t *testing.T) {
}
// nolint:paralleltest // Fixes a flake
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if runtime.GOOS == "windows" {
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) {
}
// nolint:paralleltest // Fixes a flake
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
cmd := "/bin/sh"
arg := "-c"
@@ -290,7 +287,6 @@ func Test_sshConfigExecEscapeSeparatorForce(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
found, err := sshConfigProxyCommandEscape(tt.path, tt.forceUnix)
@@ -366,7 +362,6 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
}
for _, tt := range testCases {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -688,7 +688,6 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -49,7 +49,6 @@ ExtractCommandPathsLoop:
}
for _, tt := range cases {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -60,7 +60,6 @@ func TestParse(t *testing.T) {
wantHost: "http://wow.io",
},
} {
tc := tc
t.Run(tc.in, func(t *testing.T) {
t.Parallel()
user, host, err := gitauth.ParseAskpass(tc.in)
-1
View File
@@ -48,7 +48,6 @@ func TestNotifications(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-2
View File
@@ -47,7 +47,6 @@ func Test_resolveAgentAbsPath(t *testing.T) {
{"fail with no working directory and rel path on windows", args{relOrAbsPath: "my\\path", agentOS: "windows"}, "", true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
@@ -156,7 +155,6 @@ func Test_buildAppLinkURL(t *testing.T) {
expectedLink: "https://coder.tld/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/",
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
baseURL, err := url.Parse(tt.baseURL)
-6
View File
@@ -113,7 +113,6 @@ func TestOpenVSCode(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
@@ -240,7 +239,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
@@ -414,8 +412,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
@@ -579,8 +575,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -103,7 +103,6 @@ func Test_parsePortForwards(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -145,7 +145,6 @@ func TestPortForward(t *testing.T) {
)
for _, c := range cases {
c := c
t.Run(c.name+"_OnePort", func(t *testing.T) {
t.Parallel()
p1 := setupTestListener(t, c.setupRemote(t))
-1
View File
@@ -152,7 +152,6 @@ func TestProvisionerJobs(t *testing.T) {
{"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false},
{"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false},
} {
tt := tt
wantMsg := "OK"
if !tt.wantCancelled {
wantMsg = "FAIL"
-1
View File
@@ -76,7 +76,6 @@ func Test_formatExamples(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -100,7 +100,6 @@ func TestParseCLISchedule(t *testing.T) {
expectedError: errInvalidTimeFormat.Error(),
},
} {
testCase := testCase
//nolint:paralleltest // t.Setenv
t.Run(testCase.name, func(t *testing.T) {
t.Setenv("TZ", testCase.tzEnv)
-2
View File
@@ -341,8 +341,6 @@ func TestScheduleOverride(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.command, func(t *testing.T) {
// Given
// Set timezone to Asia/Kolkata to surface any timezone-related bugs.
-5
View File
@@ -62,7 +62,6 @@ func Test_configureCipherSuites(t *testing.T) {
cipherByName := func(cipher string) *tls.CipherSuite {
for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) {
if cipher == c.Name {
c := c
return c
}
}
@@ -173,7 +172,6 @@ func Test_configureCipherSuites(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
@@ -245,7 +243,6 @@ func TestRedirectHTTPToHTTPSDeprecation(t *testing.T) {
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort)
@@ -310,7 +307,6 @@ func TestIsDERPPath(t *testing.T) {
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.path, func(t *testing.T) {
t.Parallel()
require.Equal(t, tc.expected, isDERPPath(tc.path))
@@ -363,7 +359,6 @@ func TestEscapePostgresURLUserInfo(t *testing.T) {
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.input, func(t *testing.T) {
t.Parallel()
o, err := escapePostgresURLUserInfo(tc.input)
-4
View File
@@ -471,7 +471,6 @@ func TestServer(t *testing.T) {
expectGithubDefaultProviderConfigured: true,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
runGitHubProviderTest(t, tc)
})
@@ -629,7 +628,6 @@ func TestServer(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background())
@@ -883,8 +881,6 @@ func TestServer(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
-2
View File
@@ -1517,7 +1517,6 @@ func TestSSH(t *testing.T) {
pty.ExpectMatchContext(ctx, "ping pong")
for i, sock := range sockets {
i := i
// Start the listener on the "local machine".
l, err := net.Listen("unix", sock.local)
require.NoError(t, err)
@@ -1641,7 +1640,6 @@ func TestSSH(t *testing.T) {
}
for _, tc := range tcs {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
-1
View File
@@ -343,7 +343,6 @@ func TestStartAutoUpdate(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) {
t.Parallel()
-2
View File
@@ -299,7 +299,6 @@ func TestTemplateEdit(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
@@ -416,7 +415,6 @@ func TestTemplateEdit(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
-2
View File
@@ -262,8 +262,6 @@ func TestTemplatePull_ToDir(t *testing.T) {
// nolint: paralleltest // These tests change the current working dir, and is therefore unsuitable for parallelisation.
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
dir := t.TempDir()
-1
View File
@@ -485,7 +485,6 @@ func TestTemplatePush(t *testing.T) {
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
-2
View File
@@ -30,7 +30,6 @@ func TestDurationDisplay(t *testing.T) {
{"24h1m1s", "1d"},
{"25h", "1d1h"},
} {
testCase := testCase
t.Run(testCase.Duration, func(t *testing.T) {
t.Parallel()
d, err := time.ParseDuration(testCase.Duration)
@@ -71,7 +70,6 @@ func TestExtendedParseDuration(t *testing.T) {
{"200y200y200y200y200y", 0, false},
{"9223372036854775807s", 0, false},
} {
testCase := testCase
t.Run(testCase.Duration, func(t *testing.T) {
t.Parallel()
actual, err := extendedParseDuration(testCase.Duration)
-1
View File
@@ -50,7 +50,6 @@ Full build of Coder, supports the server subcommand.
Expected: expectedText,
},
} {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
-1
View File
@@ -52,7 +52,6 @@ func TestVPNDaemonRun(t *testing.T) {
}
for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)