Skip to content

Commit 3347afb

Browse files
authored
Remove unneeded loop variable copying in Go 1.22 (#1946)
1 parent aa2afc1 commit 3347afb

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

‎.golangci.yaml‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# golangci-lint configuration file
22
# see: https://golangci-lint.run/usage/configuration/
33

4-
# Options for analysis running
5-
run:
6-
# Which dirs to skip: they won't be analyzed;
7-
skip-dirs:
8-
- bin
9-
104
# Settings of specific linters
115
linters-settings:
126
gocritic:
137
enabled-checks:
148
- dupImport
9+
disabled-checks: # temporarily disabled checks, will fix them later
10+
- appendAssign
11+
- assignOp
12+
- captLocal
13+
- commentFormatting
14+
- deprecatedComment
15+
- elseif
16+
- exitAfterDefer
17+
- ifElseChain
1518
goimports:
1619
local-prefixes: sigs.k8s.io/kueue
1720
govet:
@@ -21,10 +24,21 @@ linters-settings:
2124
# Settings for enabling and disabling linters
2225
linters:
2326
enable:
27+
- copyloopvar
2428
- dupword
2529
- ginkgolinter
2630
- gocritic
2731
- goimports
2832
- govet
2933
- misspell
3034
- unconvert
35+
36+
# Settings related to issues
37+
issues:
38+
# Which dirs to exclude: issues from them won't be reported
39+
exclude-dirs:
40+
- bin
41+
# Show all issues from a linter
42+
max-issues-per-linter: 0
43+
# Show all issues with the same text
44+
max-same-issues: 0

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
363363
GOLANGCI_LINT = $(PROJECT_DIR)/bin/golangci-lint
364364
.PHONY: golangci-lint
365365
golangci-lint: ## Download golangci-lint locally if necessary.
366-
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
366+
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
367367

368368
CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen
369369
.PHONY: controller-gen

‎pkg/queue/manager.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ func (m *Manager) AddLocalQueue(ctx context.Context, q *kueue.LocalQueue) error
200200
return fmt.Errorf("listing workloads that match the queue: %w", err)
201201
}
202202
for _, w := range workloads.Items {
203-
w := w
204203
if workload.HasQuotaReservation(&w) {
205204
continue
206205
}

‎pkg/queue/manager_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ func TestStatus(t *testing.T) {
460460
}
461461
}
462462
for _, wl := range workloads {
463-
wl := wl
464463
manager.AddOrUpdateWorkload(&wl)
465464
}
466465

‎pkg/util/priority/priority.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ func getDefaultPriorityClass(ctx context.Context, client client.Client) (*schedu
8787
// In case more than one global default priority class is added as a result of a race condition,
8888
// we pick the one with the lowest priority value.
8989
var defaultPC *schedulingv1.PriorityClass
90-
for _, pci := range pcs.Items {
91-
item := pci
92-
90+
for _, item := range pcs.Items {
9391
if item.GlobalDefault {
9492
if defaultPC == nil || defaultPC.Value > item.Value {
9593
defaultPC = &item

‎pkg/util/priority/priority_test.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ func TestGetPriorityFromPriorityClass(t *testing.T) {
135135
}
136136

137137
for desc, tt := range tests {
138-
tt := tt
139138
t.Run(desc, func(t *testing.T) {
140139
t.Parallel()
141140

@@ -200,7 +199,6 @@ func TestGetPriorityFromWorkloadPriorityClass(t *testing.T) {
200199
}
201200

202201
for desc, tt := range tests {
203-
tt := tt
204202
t.Run(desc, func(t *testing.T) {
205203
t.Parallel()
206204

0 commit comments

Comments
 (0)