Skip to content

Commit d8ea897

Browse files
committed
chore: remove unnecessary redelarations in for loops
1 parent 56ff0fb commit d8ea897

File tree

214 files changed

+296
-378
lines changed

Some content is hidden

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

214 files changed

+296
-378
lines changed

agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26
547547
// channel to synchronize the results and avoid both messy
548548
// mutex logic and overloading the API.
549549
for _, md := range manifest.Metadata {
550-
md := md
550+
551551
// We send the result to the channel in the goroutine to avoid
552552
// sending the same result multiple times. So, we don't care about
553553
// the return values.

agent/agent_test.go

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

132132
for _, port := range sshPorts {
133-
port := port
133+
134134
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
135135
t.Parallel()
136136

@@ -342,7 +342,7 @@ func TestAgent_SessionExec(t *testing.T) {
342342
t.Parallel()
343343

344344
for _, port := range sshPorts {
345-
port := port
345+
346346
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
347347
t.Parallel()
348348

@@ -468,7 +468,7 @@ func TestAgent_SessionTTYShell(t *testing.T) {
468468
}
469469

470470
for _, port := range sshPorts {
471-
port := port
471+
472472
t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) {
473473
t.Parallel()
474474

@@ -611,7 +611,7 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) {
611611
}
612612

613613
for _, test := range tests {
614-
test := test
614+
615615
t.Run(test.name, func(t *testing.T) {
616616
t.Parallel()
617617
session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) {
@@ -688,7 +688,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
688688

689689
//nolint:paralleltest // These tests need to swap the banner func.
690690
for _, port := range sshPorts {
691-
port := port
692691

693692
sshClient, err := conn.SSHClientOnPort(ctx, port)
694693
require.NoError(t, err)
@@ -697,7 +696,7 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
697696
})
698697

699698
for i, test := range tests {
700-
test := test
699+
701700
t.Run(fmt.Sprintf("(:%d)/%d", port, i), func(t *testing.T) {
702701
// Set new banner func and wait for the agent to call it to update the
703702
// banner.
@@ -1210,7 +1209,7 @@ func TestAgent_CoderEnvVars(t *testing.T) {
12101209
t.Parallel()
12111210

12121211
for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} {
1213-
key := key
1212+
12141213
t.Run(key, func(t *testing.T) {
12151214
t.Parallel()
12161215

@@ -1233,7 +1232,7 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) {
12331232
// For some reason this test produces a TTY locally and a non-TTY in CI
12341233
// so we don't test for the absence of SSH_TTY.
12351234
for _, key := range []string{"SSH_CONNECTION", "SSH_CLIENT"} {
1236-
key := key
1235+
12371236
t.Run(key, func(t *testing.T) {
12381237
t.Parallel()
12391238

@@ -1276,7 +1275,7 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) {
12761275
},
12771276
}
12781277
for _, tt := range tests {
1279-
tt := tt
1278+
12801279
t.Run(tt.key, func(t *testing.T) {
12811280
t.Parallel()
12821281

@@ -1796,7 +1795,7 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
17961795
t.Setenv("LANG", "C")
17971796

17981797
for _, backendType := range backends {
1799-
backendType := backendType
1798+
18001799
t.Run(backendType, func(t *testing.T) {
18011800
if backendType == "Screen" {
18021801
if runtime.GOOS != "linux" {
@@ -2496,7 +2495,7 @@ func TestAgent_Dial(t *testing.T) {
24962495
}
24972496

24982497
for _, c := range cases {
2499-
c := c
2498+
25002499
t.Run(c.name, func(t *testing.T) {
25012500
t.Parallel()
25022501

agent/agentcontainers/containers_internal_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestWrapDockerExec(t *testing.T) {
4141
},
4242
}
4343
for _, tt := range tests {
44-
tt := tt // appease the linter even though this isn't needed anymore
44+
// appease the linter even though this isn't needed anymore
4545
t.Run(tt.name, func(t *testing.T) {
4646
t.Parallel()
4747
actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...)
@@ -151,7 +151,7 @@ func TestConvertDockerVolume(t *testing.T) {
151151
expectError: "invalid volume",
152152
},
153153
} {
154-
tc := tc
154+
155155
t.Run(tc.name, func(t *testing.T) {
156156
t.Parallel()
157157
})

agent/agentscripts/agentscripts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S
177177
if script.Cron == "" {
178178
continue
179179
}
180-
script := script
180+
181181
_, err := r.cron.AddFunc(script.Cron, func() {
182182
err := r.trackRun(r.cronCtx, script.WorkspaceAgentScript, ExecuteCronScripts)
183183
if err != nil {
@@ -254,7 +254,6 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error {
254254
continue
255255
}
256256

257-
script := script
258257
eg.Go(func() error {
259258
err := r.trackRun(ctx, script.WorkspaceAgentScript, option)
260259
if err != nil {

agent/agentssh/x11_internal_test.go

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

230230
for _, tt := range tests {
231-
tt := tt
231+
232232
t.Run(tt.name, func(t *testing.T) {
233233
t.Parallel()
234234

agent/proto/compare_test.go

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

agent/proto/resourcesmonitor/queue_test.go

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

6767
for _, tt := range tests {
68-
tt := tt
6968

7069
t.Run(tt.name, func(t *testing.T) {
7170
t.Parallel()

agent/proto/resourcesmonitor/resources_monitor_test.go

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

197197
for _, tt := range tests {
198-
tt := tt
198+
199199
t.Run(tt.name, func(t *testing.T) {
200200
t.Parallel()
201201

apiversion/apiversion_test.go

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

buildinfo/buildinfo_test.go

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

9595
for _, c := range cases {
96-
c := c
96+
9797
t.Run(c.name, func(t *testing.T) {
9898
t.Parallel()
9999
require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy