fix(quick-13): resolve lint issues in main source files

- Fix errcheck for db.Close() in testhelper.go
- Fix errcheck, nlreturn, wsl, gofumpt issues in genevents/main.go
- Fix gofumpt and wsl issues in library.go
This commit is contained in:
2026-03-05 14:07:50 -05:00
parent 97f256d67f
commit e1a95e65a9
12 changed files with 177 additions and 61 deletions
+17 -4
View File
@@ -14,7 +14,7 @@ func newTestQueueDirect(tracks int, currentIndex int) *Queue {
}
q.tracks = make([]Track, tracks)
for i := 0; i < tracks; i++ {
for i := range tracks {
q.tracks[i] = Track{FilePath: "/test/track.mp3", Position: int64(i)}
}
@@ -135,11 +135,15 @@ func TestGenerateShuffleOrder_Properties(t *testing.T) {
// Property 2: current track is at shuffleOrder[0].
if q.shuffleOrder[0] != tc.currentIdx {
t.Errorf("shuffleOrder[0]: got %d, want %d (currentIndex)", q.shuffleOrder[0], tc.currentIdx)
t.Errorf(
"shuffleOrder[0]: got %d, want %d (currentIndex)",
q.shuffleOrder[0], tc.currentIdx,
)
}
// Property 3: all indices present (no duplicates, no missing).
seen := make(map[int]bool, tc.trackCount)
for _, idx := range q.shuffleOrder {
if idx < 0 || idx >= tc.trackCount {
t.Errorf("shuffleOrder contains out-of-range index: %d", idx)
@@ -153,7 +157,10 @@ func TestGenerateShuffleOrder_Properties(t *testing.T) {
}
if len(seen) != tc.trackCount {
t.Errorf("unique indices in shuffleOrder: got %d, want %d", len(seen), tc.trackCount)
t.Errorf(
"unique indices in shuffleOrder: got %d, want %d",
len(seen), tc.trackCount,
)
}
})
}
@@ -177,6 +184,7 @@ func TestNextIndex_ShuffleMode(t *testing.T) {
// Advance to index 4 and get next.
q.currentIndex = 4
got = q.nextIndex()
if got != 0 {
t.Errorf("nextIndex (shuffle, pos 2): got %d, want 0", got)
}
@@ -184,6 +192,7 @@ func TestNextIndex_ShuffleMode(t *testing.T) {
// At the end of shuffle order with RepeatOff.
q.currentIndex = 1 // last in shuffleOrder
got = q.nextIndex()
if got != -1 {
t.Errorf("nextIndex (shuffle, end, repeatOff): got %d, want -1", got)
}
@@ -191,7 +200,11 @@ func TestNextIndex_ShuffleMode(t *testing.T) {
// At the end of shuffle order with RepeatAll.
q.repeatMode = RepeatAll
got = q.nextIndex()
if got != 2 {
t.Errorf("nextIndex (shuffle, end, repeatAll): got %d, want 2 (wraps to shuffleOrder[0])", got)
t.Errorf(
"nextIndex (shuffle, end, repeatAll): got %d, want 2 "+
"(wraps to shuffleOrder[0])", got,
)
}
}
+12 -3
View File
@@ -35,7 +35,10 @@ func TestSaveState_RestoreState_Roundtrip(t *testing.T) {
// Each track's FilePath, Title, Artist.
for i := range s1.Tracks {
if s2.Tracks[i].FilePath != s1.Tracks[i].FilePath {
t.Errorf("track[%d] FilePath: got %q, want %q", i, s2.Tracks[i].FilePath, s1.Tracks[i].FilePath)
t.Errorf(
"track[%d] FilePath: got %q, want %q",
i, s2.Tracks[i].FilePath, s1.Tracks[i].FilePath,
)
}
if s2.Tracks[i].Title != s1.Tracks[i].Title {
@@ -43,7 +46,10 @@ func TestSaveState_RestoreState_Roundtrip(t *testing.T) {
}
if s2.Tracks[i].Artist != s1.Tracks[i].Artist {
t.Errorf("track[%d] Artist: got %q, want %q", i, s2.Tracks[i].Artist, s1.Tracks[i].Artist)
t.Errorf(
"track[%d] Artist: got %q, want %q",
i, s2.Tracks[i].Artist, s1.Tracks[i].Artist,
)
}
}
@@ -71,7 +77,10 @@ func TestSaveState_RestoreState_Roundtrip(t *testing.T) {
} else {
for i := range q.shuffleOrder {
if q2.shuffleOrder[i] != q.shuffleOrder[i] {
t.Errorf("shuffleOrder[%d]: got %d, want %d", i, q2.shuffleOrder[i], q.shuffleOrder[i])
t.Errorf(
"shuffleOrder[%d]: got %d, want %d",
i, q2.shuffleOrder[i], q.shuffleOrder[i],
)
}
}
}
+9 -3
View File
@@ -16,6 +16,7 @@ type mockTrackLoader struct {
func (m *mockTrackLoader) LoadFile(filePath string) error {
m.loadedFile = filePath
return nil
}
@@ -53,7 +54,7 @@ func seedAudioFiles(t *testing.T, db *database.DB, count int) []string {
paths := make([]string, count)
for i := 0; i < count; i++ {
for i := range count {
recID := i + 1
afID := i + 1
fp := fmt.Sprintf("/test/track%d.mp3", i+1)
@@ -68,7 +69,9 @@ func seedAudioFiles(t *testing.T, db *database.DB, count int) []string {
}
_, err = db.ExecContext(
"INSERT OR IGNORE INTO audio_files (id, file_path, length_milliseconds, file_type_id, recording_id) VALUES (?, ?, 180000, 0, ?)",
"INSERT OR IGNORE INTO audio_files (id, file_path, "+
"length_milliseconds, file_type_id, recording_id) "+
"VALUES (?, ?, 180000, 0, ?)",
afID, fp, recID,
)
if err != nil {
@@ -292,7 +295,10 @@ func TestRemoveTrack_RemoveCurrentTrack(t *testing.T) {
// After removing currentIndex=2, index should be clamped to valid range.
if state.CurrentIndex < 0 || state.CurrentIndex >= len(state.Tracks) {
t.Errorf("currentIndex out of range: got %d, track count %d", state.CurrentIndex, len(state.Tracks))
t.Errorf(
"currentIndex out of range: got %d, track count %d",
state.CurrentIndex, len(state.Tracks),
)
}
}