mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: remove unnecessary redeclarations in for loops (part 2) (#18593)
This commit is contained in:
@@ -73,7 +73,6 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error {
|
||||
var wg sync.WaitGroup
|
||||
for _, listener := range listeners {
|
||||
wg.Add(1)
|
||||
listener := listener
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
listener.send(context.Background(), message)
|
||||
|
||||
@@ -505,8 +505,6 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut
|
||||
ids := map[string]struct{}{}
|
||||
configs := []*Config{}
|
||||
for _, entry := range entries {
|
||||
entry := entry
|
||||
|
||||
// Applies defaults to the config entry.
|
||||
// This allows users to very simply state that they type is "GitHub",
|
||||
// apply their client secret and ID, and have the UI appear nicely.
|
||||
|
||||
@@ -99,7 +99,6 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat
|
||||
// membership via the groups the user is in.
|
||||
userOrgs := make(map[uuid.UUID][]database.GetGroupsRow)
|
||||
for _, g := range userGroups {
|
||||
g := g
|
||||
userOrgs[g.Group.OrganizationID] = append(userOrgs[g.Group.OrganizationID], g)
|
||||
}
|
||||
|
||||
@@ -337,8 +336,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
|
||||
|
||||
groups := make([]ExpectedGroup, 0)
|
||||
for _, group := range parsedGroups {
|
||||
group := group
|
||||
|
||||
// Legacy group mappings happen before the regex filter.
|
||||
mappedGroupName, ok := s.LegacyNameMapping[group]
|
||||
if ok {
|
||||
@@ -355,7 +352,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai
|
||||
mappedGroupIDs, ok := s.Mapping[group]
|
||||
if ok {
|
||||
for _, gid := range mappedGroupIDs {
|
||||
gid := gid
|
||||
groups = append(groups, ExpectedGroup{OrganizationID: orgID, GroupID: &gid})
|
||||
}
|
||||
continue
|
||||
|
||||
@@ -760,7 +760,6 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string,
|
||||
uniqueRoleNames := actor.SafeRoleNames()
|
||||
roleStrings := make([]string, 0, len(uniqueRoleNames))
|
||||
for _, roleName := range uniqueRoleNames {
|
||||
roleName := roleName
|
||||
roleStrings = append(roleStrings, roleName.String())
|
||||
}
|
||||
return trace.WithAttributes(
|
||||
|
||||
@@ -845,7 +845,6 @@ func Permissions(perms map[string][]policy.Action) []Permission {
|
||||
list := make([]Permission, 0, len(perms))
|
||||
for k, actions := range perms {
|
||||
for _, act := range actions {
|
||||
act := act
|
||||
list = append(list, Permission{
|
||||
Negate: false,
|
||||
ResourceType: k,
|
||||
|
||||
@@ -103,7 +103,6 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk
|
||||
var mu sync.Mutex
|
||||
var eg errgroup.Group
|
||||
for _, subscription := range subscriptions {
|
||||
subscription := subscription
|
||||
eg.Go(func() error {
|
||||
// TODO: Implement some retry logic here. For now, this is just a
|
||||
// best-effort attempt.
|
||||
|
||||
Reference in New Issue
Block a user