github-vet / github-vet/rangeloop-pointer-findings
xzl8028/xenia-server: cmd/xenia/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 [xzl8028/xenia-server](https://www.github.com/xzl8028/xenia-server) at [cmd/xenia/commands/webhook.go](https://github.com/xzl8028/xenia-server/blob/18450a97da638aff73f7749846ecf183c2253a61/cmd/xenia/commands/webhook.go#L98-L137)
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 107
[Click here to see the code in its original context.](https://github.com/xzl8028/xenia-server/blob/18450a97da638aff73f7749846ecf183c2253a61/cmd/xenia/commands/webhook.go#L98-L137)
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: 18450a97da638aff73f7749846ecf183c2253a61
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.