github-vet / github-vet/rangeloop-pointer-findings

kudobuilder/kuttl: pkg/test/case.go; 26 LoC

Open
#13,168 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [kudobuilder/kuttl](https://www.github.com/kudobuilder/kuttl) at [pkg/test/case.go](https://github.com/kudobuilder/kuttl/blob/35156480aed7aaad96a39a9922f45536614bbd63/pkg/test/case.go#L212-L237)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable testStep used in defer or goroutine at line 221

[Click here to see the code in its original context.](https://github.com/kudobuilder/kuttl/blob/35156480aed7aaad96a39a9922f45536614bbd63/pkg/test/case.go#L212-L237)

Click here to show the 26 line(s) of Go which triggered the analyzer.

```go
for _, testStep := range t.Steps {
testStep.Client = t.Client
testStep.DiscoveryClient = t.DiscoveryClient
testStep.Logger = t.Logger.WithPrefix(testStep.String())
tc.Assertions += len(testStep.Asserts)
tc.Assertions += len(testStep.Errors)

if !t.SkipDelete {
defer func() {
if err := testStep.Clean(ns.Name); err != nil {
test.Error(err)
}
}()
}

if errs := testStep.Run(ns.Name); len(errs) > 0 {
caseErr := fmt.Errorf("failed in step %s", testStep.String())
tc.Failure = report.NewFailure(caseErr.Error(), errs)

test.Error(caseErr)
for _, err := range errs {
test.Error(err)
}
break
}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 35156480aed7aaad96a39a9922f45536614bbd63

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.