github-vet / github-vet/rangeloop-pointer-findings
PaaS-TA/PaaS-TA-Monitoring: iaas-paasta-monitoring-management/src/kr/paasta/monitoring/paas/service/paas_service.go; 41 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [PaaS-TA/PaaS-TA-Monitoring](https://www.github.com/PaaS-TA/PaaS-TA-Monitoring) at [iaas-paasta-monitoring-management/src/kr/paasta/monitoring/paas/service/paas_service.go](https://github.com/PaaS-TA/PaaS-TA-Monitoring/blob/6d85fd756a2ddcb6609ca9bcf82a470eb05e851d/iaas-paasta-monitoring-management/src/kr/paasta/monitoring/paas/service/paas_service.go#L394-L434)
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 redDepIdx used in defer or goroutine at line 427
[Click here to see the code in its original context.](https://github.com/PaaS-TA/PaaS-TA-Monitoring/blob/6d85fd756a2ddcb6609ca9bcf82a470eb05e851d/iaas-paasta-monitoring-management/src/kr/paasta/monitoring/paas/service/paas_service.go#L394-L434)
Click here to show the 41 line(s) of Go which triggered the analyzer.
```go
for redDepIdx, resDep := range boshDeployments {
monitDeployments[redDepIdx].Name = resDep.Name
monitDeployments[redDepIdx].Status = model.STATE_RUNNING
wg.Add(len(resDep.VMS))
for _, resDepVm := range resDep.VMS {
go func(wg *sync.WaitGroup, resDepVm gogobosh.VM) {
defer wg.Done()
for _, paasVm := range paasSummary.Data {
if resDepVm.ID == paasVm.Id {
usage := model.Usage{utils.FloattostrDigit2(paasVm.CpuUsage)}
usages := []model.Usage{usage}
vmCpuUsage := model.BoshVmUsage{model.USAGE_NAME_CPU, paasVm.CpuState, usages}
usage = model.Usage{utils.FloattostrDigit2(paasVm.MemoryUsage)}
usages = []model.Usage{usage}
vmMemoryUsage := model.BoshVmUsage{model.USAGE_NAME_MEMORY, paasVm.MemoryState, usages}
usage = model.Usage{utils.FloattostrDigit2(paasVm.TotalDiskUsage)}
usages = []model.Usage{usage}
vmDiskRootUsage := model.BoshVmUsage{model.USAGE_NAME_DISK_ROOT, paasVm.TotalDiskState, usages}
usage = model.Usage{utils.FloattostrDigit2(paasVm.DataDiskUsage)}
usages = []model.Usage{usage}
vmDiskVcapUsage := model.BoshVmUsage{model.USAGE_NAME_DISK_VCAP, paasVm.DataDiskState, usages}
boshVm := model.BoshVm{}
boshVm.Name = paasVm.Name
boshVm.Status = paasVm.State
boshVm.BoshVmUsages = []model.BoshVmUsage{vmCpuUsage, vmMemoryUsage, vmDiskRootUsage, vmDiskVcapUsage}
monitDeployments[redDepIdx].Status = model.DetermineVmState(monitDeployments[redDepIdx].Status, boshVm.Status)
monitDeployments[redDepIdx].VMS = append(monitDeployments[redDepIdx].VMS, boshVm)
}
}
}(&wg, resDepVm)
}
wg.Wait()
}
```
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: 6d85fd756a2ddcb6609ca9bcf82a470eb05e851d
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.