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

wangboo/wwa: app/jobs/rank_data_job.go; 19 LoC

Open
#13,787 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 [wangboo/wwa](https://www.github.com/wangboo/wwa) at [app/jobs/rank_data_job.go](https://github.com/wangboo/wwa/blob/ba407ffd4a090ece24fbee577f7882d94ec06f3f/app/jobs/rank_data_job.go#L62-L80)

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 r is reassigned at line 63

[Click here to see the code in its original context.](https://github.com/wangboo/wwa/blob/ba407ffd4a090ece24fbee577f7882d94ec06f3f/app/jobs/rank_data_job.go#L62-L80)

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

```go
for _, r := range listOfRank {
rank := &r
rank.Score = 0
rank.ZoneId = s.ZoneId
rank.ZoneName = s.Name
rank.Type = t
week, err := models.FindWWAWeekByZoneIdAndUserId(s.ZoneId, rank.UserId)
if err == nil {
week.Pow = rank.Pow
weekday := time.Now().Weekday()
if weekday < 5 && weekday > 0 {
week.Type = t
}
week.Save()
}
// revel.INFO.Println("rank = ", rank)
cli.Do("ZADD", rank.ToRedisRankName(), models.RANK_SCORE_SUB, rank.ToSimpleKey())
cli.Do("HSET", "zone_user", rank.ToSimpleKey(), rank.ToDetailKey())
}

```

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: ba407ffd4a090ece24fbee577f7882d94ec06f3f

Contributor guide

No contributing guide indexed for this repository

Research direction

Read app/jobs/rank_data_job.go lines 62-80 and the linked original context first. Trace how the range-loop reference is used in the rank update and determine whether it causes incorrect behavior, then classify the finding as Bug, Mitigated, or Desirable Behavior.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.