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

bodymindarts/delmo: delmo/suite.go; 46 LoC

Open
#5,992 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 [bodymindarts/delmo](https://www.github.com/bodymindarts/delmo) at [delmo/suite.go](https://github.com/bodymindarts/delmo/blob/133c4b76654fe827abea060450d0286d673aeb43/delmo/suite.go#L49-L94)

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 test used in defer or goroutine at line 63

[Click here to see the code in its original context.](https://github.com/bodymindarts/delmo/blob/133c4b76654fe827abea060450d0286d673aeb43/delmo/suite.go#L49-L94)

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

```go
for _, test := range s.tests {
wg.Add(1)
fmt.Printf("Running test '%s'...\n", test.Name)
runner := NewTestRunner(test, s.config.Tasks, s.globalTaskEnvironment)
runtime, err := NewDockerCompose(s.config.Suite.System, test.Name)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating runtime for '%s'\n%s\n", test.Name, err)
continue
}

go func() {
defer wg.Done()

// Capture the name because the test variable will change
testName := test.Name

var output TestOutput
var outputBytes bytes.Buffer
if s.options.ParallelExecution {
output.Stdout = &outputBytes
output.Stderr = &outputBytes
} else {
output = TestOutput{
Stdout: os.Stdout,
Stderr: os.Stderr,
}
}

report := runner.RunTest(runtime, output)
if report.Success {
succeeded = append(succeeded, report)
fmt.Printf("Test '%s' completed sucessfully!\n", testName)
} else {
failed = append(failed, report)
fmt.Printf("Test '%s' Failed!\n%s\n", testName, report.Error)
if s.options.ParallelExecution {
fmt.Printf("Output from test '%s'\n%s\n", testName, outputBytes)
}
}
}()

if s.options.ParallelExecution == false {
wg.Wait()
fmt.Println("")
}
}

```

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: 133c4b76654fe827abea060450d0286d673aeb43

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.