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

miraclew/mrs: missle/match.go; 18 LoC

Open
#12,585 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 [miraclew/mrs](https://www.github.com/miraclew/mrs) at [missle/match.go](https://github.com/miraclew/mrs/blob/0dc8231f993b62a588ee96a2d0a969c5d6a99b6e/missle/match.go#L163-L180)

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.

> reference to v is reassigned at line 176

[Click here to see the code in its original context.](https://github.com/miraclew/mrs/blob/0dc8231f993b62a588ee96a2d0a969c5d6a99b6e/missle/match.go#L163-L180)

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

```go
for _, v := range m.PlayersId {
player := m.game.GetPlayer(v)
var point int32
if player.Health <= 0 {
point = -100
} else {
point = 100
}
player.MatchId = 0

UpdatePlayerPoints(v, point)

me := &pb.EMatchEnd{}
me.MatchId = &v
me.Points = &point
msg := &mnet.Message{Code: pb.Code_E_MATCH_END, MSG: me}
m.pushToUser(v, msg)
}

```

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: 0dc8231f993b62a588ee96a2d0a969c5d6a99b6e

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with missle/match.go at lines 163-180 and review how the range variable v is referenced in the reported snippet. Determine whether the analyzer finding represents a Bug, Mitigated case, or Desirable Behavior, then record the classification with the corresponding reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.