Skip to content

Commit bee64b2

Browse files
committed
Remove loop variable copies
Signed-off-by: Austin Vazquez <[email protected]>
1 parent 5d4662e commit bee64b2

File tree

70 files changed

+1
-125
lines changed

Some content is hidden

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

70 files changed

+1
-125
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
linters:
22
enable:
33
- depguard # Checks for dependencies that should not be (re)introduced. See "linter-settings" for further details.
4-
# - copyloopvar # Checks for loop variable copies in Go 1.22+
4+
- copyloopvar # Checks for loop variable copies in Go 1.22+
55
- gofmt
66
- goimports
77
- gosec

client/containerstore.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ func containerFromProto(containerpb *containersapi.Container) containers.Contain
181181
}
182182
extensions := make(map[string]typeurl.Any)
183183
for k, v := range containerpb.Extensions {
184-
v := v
185184
extensions[k] = v
186185
}
187186
return containers.Container{
@@ -203,7 +202,6 @@ func containersFromProto(containerspb []*containersapi.Container) []containers.C
203202
var containers []containers.Container
204203

205204
for _, container := range containerspb {
206-
container := container
207205
containers = append(containers, containerFromProto(container))
208206
}
209207

client/image_store.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ func imagesFromProto(imagespb []*imagesapi.Image) []images.Image {
142142
var images []images.Image
143143

144144
for _, image := range imagespb {
145-
image := image
146145
images = append(images, imageFromProto(image))
147146
}
148147

core/content/helpers_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ func TestCopy(t *testing.T) {
172172
}
173173

174174
for _, testcase := range testcases {
175-
testcase := testcase
176175
t.Run(testcase.name, func(t *testing.T) {
177176
err := Copy(context.Background(),
178177
&testcase.writer,

core/images/converter/default.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ func (c *defaultConverter) convertManifest(ctx context.Context, cs content.Store
165165
var mu sync.Mutex
166166
eg, ctx2 := errgroup.WithContext(ctx)
167167
for i, l := range manifest.Layers {
168-
i := i
169-
l := l
170168
oldDiffID, err := images.GetDiffID(ctx, cs, l)
171169
if err != nil {
172170
return nil, err
@@ -249,8 +247,6 @@ func (c *defaultConverter) convertIndex(ctx context.Context, cs content.Store, d
249247
var mu sync.Mutex
250248
eg, ctx2 := errgroup.WithContext(ctx)
251249
for i, mani := range index.Manifests {
252-
i := i
253-
mani := mani
254250
labelKey := fmt.Sprintf("containerd.io/gc.ref.content.m.%d", i)
255251
eg.Go(func() error {
256252
if mani.Platform != nil && !c.platformMC.Match(*mani.Platform) {

core/images/handlers.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ func WalkNotEmpty(ctx context.Context, handler Handler, descs ...ocispec.Descrip
154154
func Dispatch(ctx context.Context, handler Handler, limiter *semaphore.Weighted, descs ...ocispec.Descriptor) error {
155155
eg, ctx2 := errgroup.WithContext(ctx)
156156
for _, desc := range descs {
157-
desc := desc
158-
159157
if limiter != nil {
160158
if err := limiter.Acquire(ctx, 1); err != nil {
161159
return err

core/images/usage/calculator_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func TestUsageCalculation(t *testing.T) {
7272
},
7373
// TODO: Add test with snapshot
7474
} {
75-
tc := tc
7675
t.Run(tc.name, func(t *testing.T) {
7776
ctx := logtest.WithT(context.Background(), t)
7877

core/leases/lease_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func TestWithLabels(t *testing.T) {
5757
}
5858

5959
for _, tc := range testcases {
60-
tc := tc
6160
t.Run(tc.name, func(t *testing.T) {
6261
lease := newLease(tc.initialLabels)
6362
err := WithLabels(tc.labels)(lease)
@@ -66,7 +65,6 @@ func TestWithLabels(t *testing.T) {
6665
})
6766
}
6867
for _, tc := range testcases {
69-
tc := tc
7068
t.Run(tc.name+"-WithLabel", func(t *testing.T) {
7169
lease := newLease(tc.initialLabels)
7270
for k, v := range tc.labels {

core/metadata/containers_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func TestContainersList(t *testing.T) {
148148
}
149149

150150
for _, result := range results {
151-
result := result
152151
checkContainersEqual(t, &result, testset[result.ID], "list results did not match")
153152
}
154153
})
@@ -618,7 +617,6 @@ func TestContainersCreateUpdateDelete(t *testing.T) {
618617
},
619618
},
620619
} {
621-
testcase := testcase
622620
t.Run(testcase.name, func(t *testing.T) {
623621
testcase.original.ID = testcase.name
624622
if testcase.input.ID == "" {

core/metadata/gc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ func startGCContext(ctx context.Context, collectors map[gc.ResourceType]Collecto
171171
if len(collectors) > 0 {
172172
contexts = map[gc.ResourceType]CollectionContext{}
173173
for rt, collector := range collectors {
174-
rt := rt
175174
c, err := collector.StartCollection(ctx)
176175
if err != nil {
177176
// Only skipping this resource this round

0 commit comments

Comments
 (0)