github-vet / github-vet/rangeloop-pointer-findings
vsink/bsatool: bsatool.go; 59 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [vsink/bsatool](https://www.github.com/vsink/bsatool) at [bsatool.go](https://github.com/vsink/bsatool/blob/d115aeda1b4ee1f252af1b9d5cab071646f1550f/bsatool.go#L6041-L6099)
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 allloc used in defer or goroutine at line 6048
[Click here to see the code in its original context.](https://github.com/vsink/bsatool/blob/d115aeda1b4ee1f252af1b9d5cab071646f1550f/bsatool.go#L6041-L6099)
Click here to show the 59 line(s) of Go which triggered the analyzer.
```go
for _, allloc := range allLocuses {
// prod := getProductByName(allloc)
if len(altPositionsPerFile[fname][allloc]) > 2 {
dndsChan := make(chan []string)
go func() {
dndsChan <- getDnDsByLocus(allloc, altPositionsPerFile[fname][allloc])
}()
dndsRes, ok := <-dndsChan
// fmt.Println(fname, dndsRes)
if ok {
// if allloc == "Rv3879c" {
// fmt.Println(allloc, dndsRes, altPositions[allloc], fname)
// }
// fmt.Println(dndsRes)
// locDNDS[dndsRes[0]] = append(locDNDS[dndsRes[0]], dndsRes[1])
// if allloc == "Rv3854c" {
// fmt.Println(allloc, dndsRes, altPositions[allloc])
// }
// fmt.Println(allloc, dndsRes)
// locInGenome[fname][dndsRes[0]] = dndsRes[1]
if dndsRes[1] == "1.00" {
countNbrOne[allloc]++
countNeutral[fname]++
}
// close(dndsChan)
dndsPerGenomeAll[fname][dndsRes[0]] = dndsRes[1]
dndsFloat, _ = strconv.ParseFloat(dndsRes[1], 64)
geneDnDs[fname][allloc] = dndsRes[1]
if dndsFloat > 1 {
countPositive[fname]++
positiveGenes[fname] = append(positiveGenes[fname], allloc)
positiveGenesList = append(positiveGenesList, allloc)
positiveGenesCheck[allloc] = 1
} else if dndsFloat < 1 {
countNegative[fname]++
}
countNonZeroValues[allloc]++
}
} else {
// locDNDS[allloc] = append(locDNDS[allloc], "1")
// locInGenome[fname][allloc] = "1.00"
dndsPerGenomeAll[fname][allloc] = "1.00"
geneDnDs[fname][allloc] = "1.00"
// geneDnDs[fname][allloc] = "1.00"
countNeutral[fname]++
countNbrOne[allloc]++
}
}
```
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: d115aeda1b4ee1f252af1b9d5cab071646f1550f
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading bsatool.go lines 6041-6099 at the cited commit and the analyzer report about allloc in the goroutine. Decide whether the finding is a Bug, Mitigated, or Desirable Behavior, then leave the corresponding reaction; completion is the selected reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100