github-vet / github-vet/rangeloop-pointer-findings
blackducksoftware/perceptor-skyfire: pkg/skyfire/scraper.go; 28 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [blackducksoftware/perceptor-skyfire](https://www.github.com/blackducksoftware/perceptor-skyfire) at [pkg/skyfire/scraper.go](https://github.com/blackducksoftware/perceptor-skyfire/blob/594716d24cd15814c084ee0ba740adf123531387/pkg/skyfire/scraper.go#L90-L117)
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 host used in defer or goroutine at line 111
[Click here to see the code in its original context.](https://github.com/blackducksoftware/perceptor-skyfire/blob/594716d24cd15814c084ee0ba740adf123531387/pkg/skyfire/scraper.go#L90-L117)
Click here to show the 28 line(s) of Go which triggered the analyzer.
```go
for _, host := range hosts {
if sc.Hubs[host] == nil {
client, err := sc.createHubClient(host)
if err != nil {
log.Errorf("unable to instantiate hub client for %s: %s", host, err.Error())
continue
}
newDumper := &hubDumper{
client: client,
dumps: make(chan *hub.Dump),
stop: make(chan struct{}),
}
go func() {
startHubScrapes(sc.HubDumpPause, newDumper)
}()
go func() {
for {
select {
case <-newDumper.stop:
return
case dump := <-newDumper.dumps:
sc.HubDumps <- &hubDump{host: host, dump: dump}
}
}
}()
sc.Hubs[host] = newDumper
}
}
```
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: 594716d24cd15814c084ee0ba740adf123531387
Contributor guide
No contributing guide indexed for this repository
Research direction
Open pkg/skyfire/scraper.go at lines 90-117 and inspect the analyzer finding around the goroutines and range-loop variable host. Check the surrounding scraper behavior and any available project checks. Done means the reported range-loop capture issue is addressed without losing the host association for hub dumps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100