github-vet / github-vet/rangeloop-pointer-findings

auyer/MassMoverBot: mover/move.go; 23 LoC

Open
#15,173 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [auyer/MassMoverBot](https://www.github.com/auyer/MassMoverBot) at [mover/move.go](https://github.com/auyer/MassMoverBot/blob/1d05e3af1b789f1ea022f3de132693dab1e34a08/mover/move.go#L86-L108)

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 member used in defer or goroutine at line 96

[Click here to see the code in its original context.](https://github.com/auyer/MassMoverBot/blob/1d05e3af1b789f1ea022f3de132693dab1e34a08/mover/move.go#L86-L108)

Click here to show the 23 line(s) of Go which triggered the analyzer.

```go
for index, member := range guild.VoiceStates {
if member.ChannelID != dest {

if !afk && guild.AfkChannelID == member.ChannelID {
continue
}

wg.Add(1)
go func(guildID, userID, dest string, servants []*discordgo.Session, index int, errchan chan error) {
defer wg.Done()
if !utils.CheckPermissions(servants[index%len(servants)], member.ChannelID, m.Author.ID, discordgo.PermissionVoiceMoveMembers) {
return
}
err := MoveAndRetry(servants[index%len(servants)], guildID, userID, dest, 3)
if err != nil {
log.Println("Failed to move user with ID: "+userID, err)
errchan <- errors.New("bot permission")
}
}(guild.ID, member.UserID, dest, servants, index, errchan)
num++

}
}

```

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: 1d05e3af1b789f1ea022f3de132693dab1e34a08

Contributor guide

No contributing guide indexed for this repository

Research direction

Read mover/move.go lines 86-108, focusing on the range-loop variable used inside the goroutine and the analyzer's reported line 96. Check whether this affects which voice-state member is processed, then classify the finding as Bug, Mitigated, or Desirable Behavior with the corresponding reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.