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

Jpatterson780/Easy-FMS: tournament/elimination_schedule.go; 44 LoC

Open
#17,792 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 [Jpatterson780/Easy-FMS](https://www.github.com/Jpatterson780/Easy-FMS) at [tournament/elimination_schedule.go](https://github.com/Jpatterson780/Easy-FMS/blob/8e3b7e480909638b3cf075835fc92cbfdf84f861/tournament/elimination_schedule.go#L151-L194)

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.

>

[Click here to see the code in its original context.](https://github.com/Jpatterson780/Easy-FMS/blob/8e3b7e480909638b3cf075835fc92cbfdf84f861/tournament/elimination_schedule.go#L151-L194)

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

```go
for _, match := range matches {
if match.Status != "complete" {
// Update the teams in the match if they are not yet set or are incorrect.
if len(redAlliance) != 0 && !(match.Red1 == redAlliance[0].TeamId && match.Red2 == redAlliance[1].TeamId &&
match.Red3 == redAlliance[2].TeamId) {
positionRedTeams(&match, redAlliance)
match.ElimRedAlliance = redAlliance[0].AllianceId
database.SaveMatch(&match)
}
if len(blueAlliance) != 0 && !(match.Blue1 == blueAlliance[0].TeamId &&
match.Blue2 == blueAlliance[1].TeamId && match.Blue3 == blueAlliance[2].TeamId) {
positionBlueTeams(&match, blueAlliance)
match.ElimBlueAlliance = blueAlliance[0].AllianceId
database.SaveMatch(&match)
}

unplayedMatches = append(unplayedMatches, &match)
numIncomplete += 1
continue
}

// Reorder the teams based on the last complete match, so that new and unplayed matches use the same positions.
err = reorderTeams(match.Red1, match.Red2, match.Red3, redAlliance)
if err != nil {
return []model.AllianceTeam{}, err
}
err = reorderTeams(match.Blue1, match.Blue2, match.Blue3, blueAlliance)
if err != nil {
return []model.AllianceTeam{}, err
}

// Check who won.
switch match.Winner {
case "R":
redWins += 1
case "B":
blueWins += 1
case "T":
ties = append(ties, &match)
default:
return []model.AllianceTeam{}, fmt.Errorf("Completed match %d has invalid winner '%s'", match.Id,
match.Winner)
}
}

```

Click here to show extra information the analyzer produced.

```
No path was found through the callgraph that could lead to a function which writes a pointer argument.

No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.

root signature {SaveMatch 1} was not found in the callgraph; reference was passed directly to third-party code
```

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: 8e3b7e480909638b3cf075835fc92cbfdf84f861

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.