8000 chore: remove unnecessary redeclarations in for loops (part 2) (#18593) · coder/coder@09cc906 · GitHub
[go: up one dir, main page]

Skip to content

Commit 09cc906

Browse files
authored
chore: remove unnecessary redeclarations in for loops (part 2) (#18593)
1 parent e03d132 commit 09cc906

File tree

14 files changed

+0
-24
lines changed

14 files changed

+0
-24
lines changed

agent/agent.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26
565565
// channel to synchronize the results and avoid both messy
566566
// mutex logic and overloading the API.
567567
for _, md := range manifest.Metadata {
568-
md := md
569568
// We send the result to the channel in the goroutine to avoid
570569
// sending the same result multiple times. So, we don't care about
571570
// the return values.

agent/agentscripts/agentscripts.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S
149149
if script.Cron == "" {
150150
continue
151151
}
152-
script := script
153152
_, err := r.cron.AddFunc(script.Cron, func() {
154153
err := r.trackRun(r.cronCtx, script, ExecuteCronScripts)
155154
if err != nil {
@@ -224,7 +223,6 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error {
224223
continue
225224
}
226225

227-
script := script
228226
eg.Go(func() error {
229227
err := r.trackRun(ctx, script, option)
230228
if err != nil {

cli/organizationroles.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str
435435
// Construct new site perms with only new perms for the resource
436436
keep := make([]codersdk.Permission, 0)
437437
for _, perm := range role.OrganizationPermissions {
438-
perm := perm
439438
if string(perm.ResourceType) != resource {
440439
keep = append(keep, perm)
441440
}

cli/organizationsettings.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti
116116
}
117117

118118
for _, set := range settings {
119-
set := set
120119
patch := set.Patch
121120
cmd.Children = append(cmd.Children, &serpent.Command{
122121
Use: set.Name,
@@ -192,7 +191,6 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett
192191
}
193192

194193
for _, set := range settings {
195-
set := set
196194
fetch := set.Fetch
197195
cmd.Children = append(cmd.Children, &serpent.Command{
198196
Use: set.Name,

cli/server.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
11841184
var wg sync.WaitGroup
11851185
for i, provisionerDaemon := range provisionerDaemons {
11861186
id := i + 1
1187-
provisionerDaemon := provisionerDaemon
11881187
wg.Add(1)
11891188
go func() {
11901189
defer wg.Done()
@@ -1662,7 +1661,6 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion,
16621661

16631662
// Expensively check which certificate matches the client hello.
16641663
for _, cert := range certs {
1665-
cert := cert
16661664
if err := hi.SupportsCertificate(&cert); err == nil {
16671665
return &cert, nil
16681666
}

coderd/database/pubsub/pubsub_memory.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error {
7373
var wg sync.WaitGroup
7474
for _, listener := range listeners {
7575
wg.Add(1)
76-
listener := listener
7776
go func() {
7877
defer wg.Done()
7978
listener.send(context.Background(), message)

coderd/externalauth/externalauth.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,6 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut
505505
ids := map[string]struct{}{}
506506
configs := []*Config{}
507507
for _, entry := range entries {
508-
entry := entry
509-
510508
// Applies defaults to the config entry.
511509
// This allows users to very simply state that they type is "GitHub",
512510
// apply their client secret and ID, and have the UI appear nicely.

coderd/idpsync/group.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat
9999
// membership via the groups the user is in.
100100
userOrgs := make(map[uuid.UUID][]database.GetGroupsRow)
101101
for _, g := range userGroups {
102-
g := g
103102
userOrgs[g.Group.OrganizationID] = append(userOrgs[g.Group.OrganizationID], g)
104103
}
105104

@@ -337,8 +336,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
337336

338337
groups := make([]ExpectedGroup, 0)
339338
for _, group := range parsedGroups {
340-
group := group
341-
342339
// Legacy group mappings happen before the regex filter.
343340
mappedGroupName, ok := s.LegacyNameMapping[group]
344341
if ok {
@@ -355,7 +352,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
355352
mappedGroupIDs, ok := s.Mapping[group]
356353
if ok {
357354
for _, gid := range mappedGroupIDs {
358-
gid := gid
359355
groups = append(groups, ExpectedGroup{OrganizationID: orgID, GroupID: &gid})
360356
}
361357
continue

coderd/rbac/authz.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,6 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string,
760760
uniqueRoleNames := actor.SafeRoleNames()
761761
roleStrings := make([]string, 0, len(uniqueRoleNames))
762762
for _, roleName := range uniqueRoleNames {
763-
roleName := roleName
764763
roleStrings = append(roleStrings, roleName.String())
765764
}
766765
return trace.WithAttributes(

coderd/rbac/roles.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,6 @@ func Permissions(perms map[string][]policy.Action) []Permission {
845845
list := make([]Permission, 0, len(perms))
846846
for k, actions := range perms {
847847
for _, act := range actions {
848-
act := act
849848
list = append(list, Permission{
850849
Negate: false,
851850
ResourceType: k,

coderd/webpush/webpush.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk
103103
var mu sync.Mutex
104104
var eg errgroup.Group
105105
for _, subscription := range subscriptions {
106-
subscription := subscription
107106
eg.Go(func() error {
108107
// TODO: Implement some retry logic here. For now, this is just a
109108
// best-effort attempt.

enterprise/coderd/proxyhealth/proxyhealth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
240240
}
241241
// Each proxy needs to have a status set. Make a local copy for the
242242
// call to be run async.
243-
proxy := proxy
244243
status := ProxyStatus{
245244
Proxy: proxy,
246245
CheckedAt: now,

enterprise/replicasync/replicasync.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,6 @@ func (m *Manager) AllPrimary() []database.Replica {
408408
continue
409409
}
410410

411-
// When we assign the non-pointer to a
412-
// variable it loses the reference.
413-
replica := replica
414411
replicas = append(replicas, replica)
415412
}
416413
return replicas

site/site.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,6 @@ func verifyBinSha1IsCurrent(dest string, siteFS fs.FS, shaFiles map[string]strin
849849

850850
// Verify the hash of each on-disk binary.
851851
for file, hash1 := range shaFiles {
852-
file := file
853-
hash1 := hash1
854852
eg.Go(func() error {
855853
hash2, err := sha1HashFile(filepath.Join(dest, file))
856854
if err != nil {

0 commit comments

Comments
 (0)
0