github-vet / github-vet/rangeloop-pointer-findings
CodingBeard/cbcli: cli.go; 36 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [CodingBeard/cbcli](https://www.github.com/CodingBeard/cbcli) at [cli.go](https://github.com/CodingBeard/cbcli/blob/a7571108cdfe8c1134010c8660ed4f253c63bdf0/cli.go#L157-L192)
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 task used in defer or goroutine at line 174
[Click here to see the code in its original context.](https://github.com/CodingBeard/cbcli/blob/a7571108cdfe8c1134010c8660ed4f253c63bdf0/cli.go#L157-L192)
Click here to show the 36 line(s) of Go which triggered the analyzer.
```go
for _, task := range t.tasks {
if task.GetGroup() == group && task.GetName() == name {
trueVariable := true
falseVariable := false
var running *bool
if errorAfterTask, ok := task.(ErrorAfterDurationTask); ok {
go func() {
elapsed := time.Duration(0)
for true {
cbutil.Sleep(time.Second)
elapsed += time.Second
if elapsed >= errorAfterTask.GetErrorAfterDuration() {
if *running {
t.errors.Error(fmt.Errorf(
"task still running after expected duration: %s:%s %ds",
task.GetGroup(),
task.GetName(),
int(errorAfterTask.GetErrorAfterDuration()/time.Second),
))
}
break
}
}
}()
}
t.logger.InfoF("CLI", "Running task (%s:%s)", task.GetGroup(), task.GetName())
running = &trueVariable
e := task.Run()
running = &falseVariable
t.logger.InfoF("CLI", "Finished running task (%s:%s)", task.GetGroup(), task.GetName())
return e
}
}
```
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: a7571108cdfe8c1134010c8660ed4f253c63bdf0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.