Fix small lint errors found by gocritic

This commit is contained in:
Deluan 2021-07-15 13:42:54 -04:00
parent 8d56ec898e
commit b0fc684cb6
7 changed files with 8 additions and 8 deletions

View File

@ -2,10 +2,10 @@ linters:
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
- gocyclo
- goimports
- goprintffuncname
- gosec
- gosimple

View File

@ -106,7 +106,7 @@ func (a *Agents) GetSimilar(ctx context.Context, id, name, mbid string, limit in
continue
}
similar, err := agent.GetSimilar(ctx, id, name, mbid, limit)
if len(similar) >= 0 && err == nil {
if len(similar) > 0 && err == nil {
log.Debug(ctx, "Got Similar Artists", "agent", ag.AgentName(), "artist", name, "similar", similar, "elapsed", time.Since(start))
return similar, err
}

View File

@ -8,7 +8,7 @@ import (
"github.com/navidrome/navidrome/model"
)
func NewBufferedScrobbler(ds model.DataStore, s Scrobbler, service string) *bufferedScrobbler {
func newBufferedScrobbler(ds model.DataStore, s Scrobbler, service string) *bufferedScrobbler {
b := &bufferedScrobbler{ds: ds, wrapped: s, service: service}
b.wakeSignal = make(chan struct{}, 1)
go b.run()

View File

@ -53,7 +53,7 @@ func GetPlayTracker(ds model.DataStore, broker events.Broker) PlayTracker {
for name, constructor := range constructors {
s := constructor(ds)
if conf.Server.DevEnableBufferedScrobble {
s = NewBufferedScrobbler(ds, s, name)
s = newBufferedScrobbler(ds, s, name)
}
p.scrobblers[name] = s
}

View File

@ -47,8 +47,8 @@ func (ff *ffmpeg) Start(ctx context.Context, command, path string, maxBitRate in
func createTranscodeCommand(cmd, path string, maxBitRate int) []string {
split := strings.Split(cmd, " ")
for i, s := range split {
s = strings.Replace(s, "%s", path, -1)
s = strings.Replace(s, "%b", strconv.Itoa(maxBitRate), -1)
s = strings.ReplaceAll(s, "%s", path)
s = strings.ReplaceAll(s, "%b", strconv.Itoa(maxBitRate))
split[i] = s
}

View File

@ -98,7 +98,7 @@ func (r mediaFileRepository) FindByPath(path string) (*model.MediaFile, error) {
func cleanPath(path string) string {
path = filepath.Clean(path)
if !strings.HasSuffix(path, string(os.PathSeparator)) {
path = path + string(os.PathSeparator)
path += string(os.PathSeparator)
}
return path
}

View File

@ -25,7 +25,7 @@ func ParseIndexGroups(spec string) IndexGroups {
sub := re.FindStringSubmatch(g)
if len(sub) > 0 {
i := 0
chars := strings.SplitN(sub[2], "", -1)
chars := strings.Split(sub[2], "")
for _, c := range chars {
parsed[c] = sub[1]
i++