github-vet / github-vet/rangeloop-pointer-findings
tox2ik/ttrack: io.go; 23 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [tox2ik/ttrack](https://www.github.com/tox2ik/ttrack) at [io.go](https://github.com/tox2ik/ttrack/blob/1bf1aebf3e7886bfaa05994c52f02597c4940df7/io.go#L76-L98)
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 rec was used in a composite literal at line 94
[Click here to see the code in its original context.](https://github.com/tox2ik/ttrack/blob/1bf1aebf3e7886bfaa05994c52f02597c4940df7/io.go#L76-L98)
Click here to show the 23 line(s) of Go which triggered the analyzer.
```go
for i, rec := range records {
if rec.isIn() {
last = rec
day = rec.Day
in = rec.Stamp
}
if rec.isOut() {
if day != rec.Day {
// todo: should support over-midnight stamps
debug("warn: day mismatch for Record: %d (%s,%s)", i, day, rec.Day)
}
allTuples = append(
allTuples,
Tuple{
Day: day,
Seconds: float32(rec.Stamp - in),
in: &last, // Unnecessary to keep reference here.
out: &rec, // Should just set isValid if both present.
})
day = ""
}
}
```
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: 1bf1aebf3e7886bfaa05994c52f02597c4940df7
Contributor guide
No contributing guide indexed for this repository
Research direction
Inspect io.go lines 76-98 and the referenced commit, starting with the analyzer's range-loop pointer finding. Determine whether the references to rec and last are a bug, mitigated, or desirable behavior, then classify the issue 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
- Needs clarification
- Newbie friendliness
- 30/100