Skip to content

Commit

Permalink
Lint for exported loop var pointers and fix occurences
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroaleman committed Jul 16, 2021
1 parent 8ffcabe commit 172ad4e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ linters:
- ineffassign
- staticcheck
- gosimple
- exportloopref
disable-all: true

issues:
Expand Down
3 changes: 3 additions & 0 deletions prow/cmd/deck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,9 @@ func handleArtifactView(o options, sg *spyglass.Spyglass, cfg config.Getter) htt
var lens *config.LensFileConfig
for _, configLens := range cfg().Deck.Spyglass.Lenses {
if configLens.Lens.Name == lensName {

// Directly followed by break, so this is ok
// nolint: exportloopref
lens = &configLens
break
}
Expand Down
1 change: 1 addition & 0 deletions prow/plugins/bugzilla/bugzilla_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ Instructions for interacting with me using PR comments are available [here](http
gc.IssueLabelsExisting = append(gc.IssueLabelsExisting, fmt.Sprintf("%s/%s#%d:%s", e.org, e.repo, e.number, label))
}
for _, pr := range testCase.prs {
pr := pr
gc.PullRequests[pr.Number] = &pr
}
bc := bugzilla.Fake{
Expand Down
3 changes: 3 additions & 0 deletions prow/plugins/cla/cla_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ func TestCLALabels(t *testing.T) {
for _, tc := range testcases {
pullRequests := make(map[int]*github.PullRequest)
for _, pr := range tc.pullRequests {
pr := pr
pullRequests[pr.Number] = &pr
}

issues := make(map[int]*github.Issue)
for _, issue := range tc.issues {
issue := issue
issues[issue.Number] = &issue
}

Expand Down Expand Up @@ -337,6 +339,7 @@ func TestCheckCLA(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
pullRequests := make(map[int]*github.PullRequest)
for _, pr := range tc.pullRequests {
pr := pr
pullRequests[pr.Number] = &pr
}
fc := fakegithub.NewFakeClient()
Expand Down
3 changes: 3 additions & 0 deletions prow/pubsub/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func (peh *periodicJobHandler) getProwJobSpec(cfg prowCfgClient, pe ProwJobEvent
// https://github.com/kubernetes/test-infra/issues/21729 is done?
for _, job := range cfg.AllPeriodics() {
if job.Name == pe.Name {
// Directly followed by break, so this is ok
// nolint: exportloopref
periodicJob = &job
break
}
Expand Down Expand Up @@ -268,6 +270,7 @@ func (poh *postsubmitJobHandler) getProwJobSpec(cfg prowCfgClient, pe ProwJobEve
}

for _, job := range postsubmits {
job := job
if !job.CouldRun(branch) { // filter out jobs that are not branch matching
continue
}
Expand Down
1 change: 1 addition & 0 deletions prow/tide/tide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,7 @@ func testTakeAction(clients localgit.Clients, t *testing.T) {
t.Errorf("prowjob %q didn't have expected namespace %q but %q", pj.Name, pjNamespace, pj.Namespace)
}
if pj.Spec.Type == prowapi.BatchJob {
pj := pj
batchJobs = append(batchJobs, &pj)
}
}
Expand Down

0 comments on commit 172ad4e

Please sign in to comment.