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

jypelle/mifasol: srv/svc/artist.go; 24 LoC

Open
#15,497 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 [jypelle/mifasol](https://www.github.com/jypelle/mifasol) at [srv/svc/artist.go](https://github.com/jypelle/mifasol/blob/f9bcc29dcfdaa476b5622d8c7bf4dafe1c7eda44/srv/svc/artist.go#L280-L303)

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

[Click here to see the code in its original context.](https://github.com/jypelle/mifasol/blob/f9bcc29dcfdaa476b5622d8c7bf4dafe1c7eda44/srv/svc/artist.go#L280-L303)

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

```go
for _, artistName := range artistNames {
artistName = normalizeString(artistName)
if artistName != "" {
var artists []restApiV1.Artist
artists, e = s.ReadArtists(txn, &restApiV1.ArtistFilter{Name: &artistName})

if e != nil {
return nil, e
}
var artistId restApiV1.ArtistId
if len(artists) > 0 {
// Link the song to an existing artist
artistId = artists[0].Id
} else {
// Create the artist before linking it to the song
artist, err := s.CreateArtist(txn, &restApiV1.ArtistMeta{Name: artistName})
if err != nil {
return nil, err
}
artistId = artist.Id
}
artistIds = append(artistIds, artistId)
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with srv/svc/artist.go at lines 280-303 and read how artistName is used in the range loop and passed into ArtistFilter and ArtistMeta. Determine whether the analyzer's reference warning represents a real bug, a mitigated case, or desirable behavior. Done means leaving the appropriate reaction classification on this issue.

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.