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

jwoos/rainbowgif: quantize.go; 16 LoC

Open
#16,463 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 [jwoos/rainbowgif](https://www.github.com/jwoos/rainbowgif) at [quantize.go](https://github.com/jwoos/rainbowgif/blob/f55fd45f6c1a90ad9f00088e289915c0ac5abe3a/quantize.go#L53-L68)

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 c was used in a composite literal at line 60

[Click here to see the code in its original context.](https://github.com/jwoos/rainbowgif/blob/f55fd45f6c1a90ad9f00088e289915c0ac5abe3a/quantize.go#L53-L68)

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

```go
for i, c := range colors {
colorInfo, okay := palette[c]
if !okay {
colorInfo = struct {
addr *color.RGBA
index int
}{
addr: &c,
index: len(paletteSlice),
}
palette[c] = colorInfo
paletteSlice = append(paletteSlice, colorInfo.addr)
}

indexMapping[i] = colorInfo.index
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Open quantize.go at lines 53-68 in the linked rainbowgif commit and read the surrounding range-loop code first. Decide whether the reported reference to c is a bug, mitigated, or desirable behavior, then record the corresponding reaction on this issue; completion is a single classification reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.