github-vet / github-vet/rangeloop-pointer-findings
knative/test-infra: tools/flaky-test-reporter/slack_notification.go; 33 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [knative/test-infra](https://www.github.com/knative/test-infra) at [tools/flaky-test-reporter/slack_notification.go](https://github.com/knative/test-infra/blob/d99502731eb66f24a2912a1f0f6537d2771bfd34/tools/flaky-test-reporter/slack_notification.go#L77-L109)
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 rd used in defer or goroutine at line 90
[Click here to see the code in its original context.](https://github.com/knative/test-infra/blob/d99502731eb66f24a2912a1f0f6537d2771bfd34/tools/flaky-test-reporter/slack_notification.go#L77-L109)
Click here to show the 33 line(s) of Go which triggered the analyzer.
```go
for _, rd := range repoDataAll {
channels := rd.Config.SlackChannels
if len(channels) == 0 {
log.Printf("cannot find Slack channel for job '%s' in repo '%s', skipping Slack notification", rd.Config.Name, rd.Config.Repo)
continue
}
ch := make(chan bool, len(channels))
wg := sync.WaitGroup{}
for i := range channels {
wg.Add(1)
channel := channels[i]
go func() {
defer wg.Done()
message := createSlackMessageForRepo(rd, flakyIssues)
if err := helpers.Run(
fmt.Sprintf("post Slack message for job '%s' from repo '%s' in channel '%s'", rd.Config.Name, rd.Config.Repo, channel.Name),
func() error {
return c.Post(message, channel.Identity)
},
dryrun,
); err != nil {
allErrs = append(allErrs, err)
log.Printf("failed sending notification to Slack channel '%s': '%v'", channel.Name, err)
}
if dryrun {
log.Printf("[dry run] Slack message not sent. See it below:\n%s\n\n", message)
}
ch <- true
}()
}
wg.Wait()
close(ch)
}
```
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: d99502731eb66f24a2912a1f0f6537d2771bfd34
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.