Skip to content

Commit

Permalink
Remove unneeded loop variable copying in Go 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Apr 4, 2024
1 parent 1aa8ade commit 88a5db8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
26 changes: 20 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# golangci-lint configuration file
# see: https://golangci-lint.run/usage/configuration/

# Options for analysis running
run:
# Which dirs to skip: they won't be analyzed;
skip-dirs:
- bin

# Settings of specific linters
linters-settings:
gocritic:
enabled-checks:
- dupImport
disabled-checks: # temporarily disabled checks, will fix them later
- appendAssign
- assignOp
- captLocal
- commentFormatting
- deprecatedComment
- elseif
- exitAfterDefer
- ifElseChain
goimports:
local-prefixes: sigs.k8s.io/kueue
govet:
Expand All @@ -21,10 +24,21 @@ linters-settings:
# Settings for enabling and disabling linters
linters:
enable:
- copyloopvar
- dupword
- ginkgolinter
- gocritic
- goimports
- govet
- misspell
- unconvert

# Settings related to issues
issues:
# Which dirs to exclude: issues from them won't be reported
exclude-dirs:
- bin
# Show all issues from a linter
max-issues-per-linter: 0
# Show all issues with the same text
max-same-issues: 0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
GOLANGCI_LINT = $(PROJECT_DIR)/bin/golangci-lint
.PHONY: golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2

CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen
.PHONY: controller-gen
Expand Down
1 change: 0 additions & 1 deletion pkg/queue/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func (m *Manager) AddLocalQueue(ctx context.Context, q *kueue.LocalQueue) error
return fmt.Errorf("listing workloads that match the queue: %w", err)
}
for _, w := range workloads.Items {
w := w
if workload.HasQuotaReservation(&w) {
continue
}
Expand Down
1 change: 0 additions & 1 deletion pkg/queue/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ func TestStatus(t *testing.T) {
}
}
for _, wl := range workloads {
wl := wl
manager.AddOrUpdateWorkload(&wl)
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/util/priority/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ func getDefaultPriorityClass(ctx context.Context, client client.Client) (*schedu
// In case more than one global default priority class is added as a result of a race condition,
// we pick the one with the lowest priority value.
var defaultPC *schedulingv1.PriorityClass
for _, pci := range pcs.Items {
item := pci

for _, item := range pcs.Items {
if item.GlobalDefault {
if defaultPC == nil || defaultPC.Value > item.Value {
defaultPC = &item
Expand Down
2 changes: 0 additions & 2 deletions pkg/util/priority/priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func TestGetPriorityFromPriorityClass(t *testing.T) {
}

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

Expand Down Expand Up @@ -200,7 +199,6 @@ func TestGetPriorityFromWorkloadPriorityClass(t *testing.T) {
}

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

Expand Down

0 comments on commit 88a5db8

Please sign in to comment.