Add nilerr linter

This commit is contained in:
Deluan 2022-09-30 20:18:14 -04:00
parent 364e699ac1
commit f82df70302
7 changed files with 11 additions and 10 deletions

View File

@ -20,6 +20,7 @@ linters:
- govet
- ineffassign
- misspell
- nilerr
- rowserrcheck
- staticcheck
- typecheck

View File

@ -54,7 +54,7 @@ func (a *Agents) GetMBID(ctx context.Context, id string, name string) (string, e
mbid, err := agent.GetMBID(ctx, id, name)
if mbid != "" && err == nil {
log.Debug(ctx, "Got MBID", "agent", ag.AgentName(), "artist", name, "mbid", mbid, "elapsed", time.Since(start))
return mbid, err
return mbid, nil
}
}
return "", ErrNotFound
@ -73,7 +73,7 @@ func (a *Agents) GetURL(ctx context.Context, id, name, mbid string) (string, err
url, err := agent.GetURL(ctx, id, name, mbid)
if url != "" && err == nil {
log.Debug(ctx, "Got External Url", "agent", ag.AgentName(), "artist", name, "url", url, "elapsed", time.Since(start))
return url, err
return url, nil
}
}
return "", ErrNotFound
@ -92,7 +92,7 @@ func (a *Agents) GetBiography(ctx context.Context, id, name, mbid string) (strin
bio, err := agent.GetBiography(ctx, id, name, mbid)
if bio != "" && err == nil {
log.Debug(ctx, "Got Biography", "agent", ag.AgentName(), "artist", name, "len", len(bio), "elapsed", time.Since(start))
return bio, err
return bio, nil
}
}
return "", ErrNotFound
@ -134,7 +134,7 @@ func (a *Agents) GetImages(ctx context.Context, id, name, mbid string) ([]Artist
images, err := agent.GetImages(ctx, id, name, mbid)
if len(images) > 0 && err == nil {
log.Debug(ctx, "Got Images", "agent", ag.AgentName(), "artist", name, "images", images, "elapsed", time.Since(start))
return images, err
return images, nil
}
}
return nil, ErrNotFound
@ -153,7 +153,7 @@ func (a *Agents) GetTopSongs(ctx context.Context, id, artistName, mbid string, c
songs, err := agent.GetTopSongs(ctx, id, artistName, mbid, count)
if len(songs) > 0 && err == nil {
log.Debug(ctx, "Got Top Songs", "agent", ag.AgentName(), "artist", artistName, "songs", songs, "elapsed", time.Since(start))
return songs, err
return songs, nil
}
}
return nil, ErrNotFound

View File

@ -25,7 +25,7 @@ func (r propertyRepository) Put(id string, value string) error {
update := Update(r.tableName).Set("value", value).Where(Eq{"id": id})
count, err := r.executeSQL(update)
if err != nil {
return nil
return err
}
if count > 0 {
return nil

View File

@ -25,7 +25,7 @@ func (r userPropsRepository) Put(userId, key string, value string) error {
update := Update(r.tableName).Set("value", value).Where(And{Eq{"user_id": userId}, Eq{"key": key}})
count, err := r.executeSQL(update)
if err != nil {
return nil
return err
}
if count > 0 {
return nil

View File

@ -53,7 +53,7 @@ func (p *MockedPropertyRepo) DefaultGet(id string, defaultValue string) (string,
p.init()
v, err := p.Get(id)
if err != nil {
return defaultValue, nil
return defaultValue, nil //nolint:nilerr
}
return v, nil
}

View File

@ -53,7 +53,7 @@ func (p *MockedUserPropsRepo) DefaultGet(userId, key string, defaultValue string
p.init()
v, err := p.Get(userId, key)
if err != nil {
return defaultValue, nil
return defaultValue, nil //nolint:nilerr
}
return v, nil
}

View File

@ -47,7 +47,7 @@ func (sfs *spreadFS) Reload(f func(key string, name string)) error {
}
path, err := filepath.Rel(sfs.root, absoluteFilePath)
if err != nil {
return nil
return nil //nolint:nilerr
}
// Skip if name is not in the format XX/XX/XXXXXXXXXXXX