fix: resolve all lint errors and make linting a required CI check (#62)
- Fix 10 err113 violations: extract dynamic errors to package-level sentinels - Fix 12 errcheck violations: handle unchecked error returns in player, metadata, and config packages - Fix 4 revive stutter warnings: rename player.PlayerState to player.State, player.PlayerVolume to player.Volume, queue.QueueTrack to queue.Track, queue.QueueState to queue.State - Fix 2 staticcheck SA4001: simplify *&x to x in assets handler - Fix 5 unused constants: remove dead AudioFileType iota block in models - Fix gci/gofumpt/wsl formatting issues across multiple files - Add gofumpt module-path setting to .golangci.yml for correct import grouping - Fix player test: gate integration test behind YELLOWJACKET_INTEGRATION env var instead of only skipping in CI, and replace t.Errorf+t.Failed with t.Fatalf - Remove continue-on-error from golangci-lint CI step so linting is now required
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
package library
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var errNotDirectory = errors.New("path is not a directory")
|
||||
|
||||
// Config holds Library config data.
|
||||
type Config struct {
|
||||
DirectoryPath Directory `form:"Directory" schema:"directory,required"`
|
||||
@@ -35,7 +38,7 @@ func (c *Config) Validate() error {
|
||||
}
|
||||
|
||||
if !dirInfo.IsDir() {
|
||||
return fmt.Errorf("%s is not a directory", c.DirectoryPath)
|
||||
return fmt.Errorf("%s: %w", c.DirectoryPath, errNotDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,15 @@ import (
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"yellowjacket/backend/database"
|
||||
"yellowjacket/backend/database/sql/sqlcgen"
|
||||
"yellowjacket/backend/events"
|
||||
"yellowjacket/backend/metadata"
|
||||
)
|
||||
|
||||
var errLibraryDirNotConfigured = errors.New("library directory not configured")
|
||||
|
||||
// Library manages scanning and querying the music collection.
|
||||
type Library struct {
|
||||
ctx context.Context
|
||||
@@ -107,7 +110,7 @@ func (l *Library) Scan() error {
|
||||
l.logger.Info("beginning library scan", "workers", scanWorkerCount)
|
||||
|
||||
if len(l.conf.DirectoryPath) == 0 {
|
||||
return errors.New("library directory not configured")
|
||||
return errLibraryDirNotConfigured
|
||||
}
|
||||
|
||||
// Load existing file paths from the database into a sync.Map for concurrent access.
|
||||
|
||||
@@ -7,6 +7,12 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Sentinel errors for library queries.
|
||||
var (
|
||||
errNoTracksInLibrary = errors.New("no tracks in library")
|
||||
errNoTracksForAlbum = errors.New("no tracks found for album")
|
||||
)
|
||||
|
||||
// Track represents a playable audio file in the library.
|
||||
type Track struct {
|
||||
TrackName string
|
||||
@@ -38,7 +44,7 @@ func (l *Library) GetAllTracks() ([]Track, error) {
|
||||
if len(audioFiles) == 0 {
|
||||
l.logger.Error("no tracks in library")
|
||||
|
||||
return nil, errors.New("no tracks in library")
|
||||
return nil, errNoTracksInLibrary
|
||||
}
|
||||
|
||||
var formattedTracks []Track
|
||||
@@ -68,7 +74,7 @@ func (l *Library) GetAlbumTracks(albumID int64) ([]Track, error) {
|
||||
}
|
||||
|
||||
if len(rows) == 0 {
|
||||
return nil, fmt.Errorf("no tracks found for album %d", albumID)
|
||||
return nil, fmt.Errorf("%w %d", errNoTracksForAlbum, albumID)
|
||||
}
|
||||
|
||||
tracks := make([]Track, 0, len(rows))
|
||||
|
||||
Reference in New Issue
Block a user