github-vet / github-vet/rangeloop-pointer-findings
wix-playground/tfChek: launcher/wtftask.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [wix-playground/tfChek](https://www.github.com/wix-playground/tfChek) at [launcher/wtftask.go](https://github.com/wix-playground/tfChek/blob/a013a616b416507c1a7b68502c66ed126f45dc5b/launcher/wtftask.go#L429-L478)
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 gurl used in defer or goroutine at line 441
[Click here to see the code in its original context.](https://github.com/wix-playground/tfChek/blob/a013a616b416507c1a7b68502c66ed126f45dc5b/launcher/wtftask.go#L429-L478)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for gurl, gitman := range gms {
gmwg.Add(1)
go func(manager git.Manager, errChan chan<- error) {
defer gmwg.Done()
//Wait for corresponding webhook to come
misc.Debugf("Waiting for a webhook to come from %s repo for a task %d", manager.GetRemote(), w.id)
wht := viper.GetInt(misc.WebhookWaitTimeoutKey)
err := manager.WaitForWebhook(branch, wht)
if err != nil {
errChan <- fmt.Errorf("failed to wait for a webhook lock. Error: %w", err)
return
}
misc.Debugf("Preparing Git repo %s", gurl)
//Clone it if needed
if manager.IsCloned() {
err := manager.Open()
if err != nil {
log.Printf("Cannot open git repository. Error: %s", err)
errChan <- err
return
}
} else {
path := manager.GetPath()
_, err := os.Stat(path)
if os.IsNotExist(err) {
err := os.MkdirAll(path, 0755)
if err != nil {
log.Printf("Cannot create directory for git repository. Error: %s", err)
errChan <- err
return
}
}
err = manager.Clone()
if err != nil {
log.Printf("Cannot clone repository. Error: %s", err)
errChan <- err
return
}
}
//Switch the branch
err = manager.SwitchTo(branch)
if err != nil {
log.Printf("Cannot switch branch")
errChan <- err
return
}
}(gitman, errc)
}
```
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: a013a616b416507c1a7b68502c66ed126f45dc5b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.