github-vet / github-vet/rangeloop-pointer-findings
smart0329/SFP_WEB: cmd/mattermost/commands/webhook.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [smart0329/SFP_WEB](https://www.github.com/smart0329/SFP_WEB) at [cmd/mattermost/commands/webhook.go](https://github.com/smart0329/SFP_WEB/blob/b8e5230b743f4a9af29807b2947596723e0ebadb/cmd/mattermost/commands/webhook.go#L108-L147)
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 team used in defer or goroutine at line 117
[Click here to see the code in its original context.](https://github.com/smart0329/SFP_WEB/blob/b8e5230b743f4a9af29807b2947596723e0ebadb/cmd/mattermost/commands/webhook.go#L108-L147)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for i, team := range teams {
if team == nil {
CommandPrintErrorln("Unable to find team '" + args[i] + "'")
continue
}
// Fetch all hooks with a very large limit so we get them all.
incomingResult := make(chan store.StoreResult, 1)
go func() {
incomingHooks, err := app.Srv.Store.Webhook().GetIncomingByTeam(team.Id, 0, 100000000)
incomingResult <- store.StoreResult{Data: incomingHooks, Err: err}
close(incomingResult)
}()
outgoingResult := make(chan store.StoreResult, 1)
go func() {
outgoingHooks, err := app.Srv.Store.Webhook().GetOutgoingByTeam(team.Id, 0, 100000000)
outgoingResult <- store.StoreResult{Data: outgoingHooks, Err: err}
close(outgoingResult)
}()
if result := <-incomingResult; result.Err == nil {
CommandPrettyPrintln(fmt.Sprintf("Incoming webhooks for %s (%s):", team.DisplayName, team.Name))
hooks := result.Data.([]*model.IncomingWebhook)
for _, hook := range hooks {
CommandPrettyPrintln("\t" + hook.DisplayName + " (" + hook.Id + ")")
}
} else {
CommandPrintErrorln("Unable to list incoming webhooks for '" + args[i] + "'")
}
if result := <-outgoingResult; result.Err == nil {
hooks := result.Data.([]*model.OutgoingWebhook)
CommandPrettyPrintln(fmt.Sprintf("Outgoing webhooks for %s (%s):", team.DisplayName, team.Name))
for _, hook := range hooks {
CommandPrettyPrintln("\t" + hook.DisplayName + " (" + hook.Id + ")")
}
} else {
CommandPrintErrorln("Unable to list outgoing webhooks for '" + args[i] + "'")
}
}
```
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: b8e5230b743f4a9af29807b2947596723e0ebadb
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.