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

chore: remove unnecessary redeclarations in for loops#18440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aslilac wants to merge3 commits intomain
base:main
Choose a base branch
Loading
fromlilac/go-122-range-fix
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletionagent/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -547,7 +547,6 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26
// channel to synchronize the results and avoid both messy
// mutex logic and overloading the API.
for _, md := range manifest.Metadata {
md := md
// We send the result to the channel in the goroutine to avoid
// sending the same result multiple times. So, we don't care about
// the return values.
Expand Down
12 changes: 0 additions & 12 deletionsagent/agent_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -130,7 +130,6 @@ func TestAgent_Stats_SSH(t *testing.T) {
t.Parallel()

for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
t.Parallel()

Expand DownExpand Up@@ -342,7 +341,6 @@ func TestAgent_SessionExec(t *testing.T) {
t.Parallel()

for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
t.Parallel()

Expand DownExpand Up@@ -468,7 +466,6 @@ func TestAgent_SessionTTYShell(t *testing.T) {
}

for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) {
t.Parallel()

Expand DownExpand Up@@ -611,7 +608,6 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) {
Expand DownExpand Up@@ -688,16 +684,13 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {

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

sshClient, err := conn.SSHClientOnPort(ctx, port)
require.NoError(t, err)
t.Cleanup(func() {
_ = sshClient.Close()
})

for i, test := range tests {
test := test
t.Run(fmt.Sprintf("(:%d)/%d", port, i), func(t *testing.T) {
// Set new banner func and wait for the agent to call it to update the
// banner.
Expand DownExpand Up@@ -1210,7 +1203,6 @@ func TestAgent_CoderEnvVars(t *testing.T) {
t.Parallel()

for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} {
key := key
t.Run(key, func(t *testing.T) {
t.Parallel()

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

Expand DownExpand Up@@ -1276,7 +1267,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.key, func(t *testing.T) {
t.Parallel()

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

for _, backendType := range backends {
backendType := backendType
t.Run(backendType, func(t *testing.T) {
if backendType == "Screen" {
if runtime.GOOS != "linux" {
Expand DownExpand Up@@ -2496,7 +2485,6 @@ func TestAgent_Dial(t *testing.T) {
}

for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletionsagent/agentcontainers/containers_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,6 @@ func TestWrapDockerExec(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt // appease the linter even though this isn't needed anymore
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...)
Expand All@@ -54,7 +53,6 @@ func TestWrapDockerExec(t *testing.T) {
func TestConvertDockerPort(t *testing.T) {
t.Parallel()

//nolint:paralleltest // variable recapture no longer required
for _, tc := range []struct {
name string
in string
Expand DownExpand Up@@ -101,7 +99,6 @@ func TestConvertDockerPort(t *testing.T) {
expectError: "invalid port",
},
} {
//nolint: paralleltest // variable recapture no longer required
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
actualPort, actualNetwork, actualErr := convertDockerPort(tc.in)
Expand DownExpand Up@@ -151,7 +148,6 @@ func TestConvertDockerVolume(t *testing.T) {
expectError: "invalid volume",
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
})
Expand Down
2 changes: 0 additions & 2 deletionsagent/agentscripts/agentscripts.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -177,7 +177,6 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S
if script.Cron == "" {
continue
}
script := script
_, err := r.cron.AddFunc(script.Cron, func() {
err := r.trackRun(r.cronCtx, script.WorkspaceAgentScript, ExecuteCronScripts)
if err != nil {
Expand DownExpand Up@@ -254,7 +253,6 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error {
continue
}

script := script
eg.Go(func() error {
err := r.trackRun(ctx, script.WorkspaceAgentScript, option)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletionagent/agentssh/x11_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -228,7 +228,6 @@ func Test_addXauthEntry(t *testing.T) {
require.NoError(t, err)

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletionagent/proto/compare_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,6 @@ func TestLabelsEqual(t *testing.T) {
eq: false,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, tc.eq, proto.LabelsEqual(tc.a, tc.b))
Expand Down
2 changes: 0 additions & 2 deletionsagent/proto/resourcesmonitor/queue_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,8 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) {
}

for _, tt := range tests {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()
queue := resourcesmonitor.NewQueue(20)
Expand Down
1 change: 0 additions & 1 deletionagent/proto/resourcesmonitor/resources_monitor_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -195,7 +195,6 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletionapiversion/apiversion_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,7 +72,6 @@ func TestAPIVersionValidate(t *testing.T) {
expectedError: "no longer supported",
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletionbuildinfo/buildinfo_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,6 @@ func TestBuildInfo(t *testing.T) {
}

for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2),
Expand Down
1 change: 0 additions & 1 deletioncli/agent_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
1 change: 0 additions & 1 deletioncli/autoupdate_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
1 change: 0 additions & 1 deletioncli/clitest/golden.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
3 changes: 0 additions & 3 deletionscli/cliui/agent_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -369,7 +369,6 @@ func TestAgent(t *testing.T) {
wantErr: true,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand DownExpand Up@@ -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()
Expand DownExpand Up@@ -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()
Expand Down
2 changes: 0 additions & 2 deletionscli/cliui/provisionerjob_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()

Expand Down
1 change: 0 additions & 1 deletioncli/cliui/resources_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
1 change: 0 additions & 1 deletioncli/cliui/table_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
2 changes: 0 additions & 2 deletionscli/cliutil/levenshtein/levenshtein_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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...)
Expand DownExpand Up@@ -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)
Expand Down
1 change: 0 additions & 1 deletioncli/cliutil/provisionerwarn_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
5 changes: 0 additions & 5 deletionscli/configssh_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()

Expand DownExpand Up@@ -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.")
Expand DownExpand Up@@ -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"
Expand DownExpand Up@@ -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)
Expand DownExpand Up@@ -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()

Expand Down
1 change: 0 additions & 1 deletioncli/configssh_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()

Expand Down
1 change: 0 additions & 1 deletioncli/exp_errors_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,6 @@ ExtractCommandPathsLoop:
}

for _, tt := range cases {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletioncli/gitauth/askpass_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
1 change: 0 additions & 1 deletioncli/notifications_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()

Expand Down
2 changes: 0 additions & 2 deletionscli/open_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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()

Expand DownExpand Up@@ -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)
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp