fix: dead code and staticcheck findings
Removes unused functions (sortedDirs, artistDirOfPlan, alArtistCredit, editorFixesAll, Plan.nameSession and a dead test helper), the ineffective assignment to the never-read Module.contentRows field, a duplicated condition in scan.collectAudio and two loops staticcheck flagged in internal/audio. staticcheck -checks=all is now clean. Closes 313278a
diff --git a/internal/audio/audio.go b/internal/audio/audio.go
@@ -98,10 +98,7 @@ func vorbiscommentTags(ctx context.Context, path string) ([]tags.Note, error) {
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("vorbiscomment %s: %s", filepath.Base(path), strings.TrimSpace(errb.String()))
}
- var lines []string
- for _, l := range strings.Split(out.String(), "\n") {
- lines = append(lines, l)
- }
+ lines := strings.Split(out.String(), "\n")
return tags.Parse(lines), nil
}
@@ -187,10 +184,7 @@ func metaflacTags(ctx context.Context, path string) ([]tags.Note, error) {
if err := cmd.Run(); err != nil {
return nil, fmt.Errorf("metaflac %s: %s", filepath.Base(path), strings.TrimSpace(errb.String()))
}
- var lines []string
- for _, l := range strings.Split(out.String(), "\n") {
- lines = append(lines, l)
- }
+ lines := strings.Split(out.String(), "\n")
return tags.Parse(lines), nil
}
diff --git a/internal/scan/scan.go b/internal/scan/scan.go
@@ -162,7 +162,7 @@ func collectAudio(dir string, a *Album) ([]string, map[string]int, error) {
}
}
}
- case strings.HasPrefix(e.Name(), "."), strings.HasPrefix(e.Name(), "."):
+ case strings.HasPrefix(e.Name(), "."), strings.HasPrefix(e.Name(), "._"):
continue
default:
if audio.IsAudio(e.Name()) {
diff --git a/internal/tui/preview_test.go b/internal/tui/preview_test.go
@@ -129,25 +129,6 @@ func TestChafaIsOptional(t *testing.T) {
var _ = exec.Command
-func makeBigImage(t *testing.T, path string) {
- t.Helper()
- const n = 400
- img := image.NewRGBA(image.Rect(0, 0, n, n))
- for y := 0; y < n; y++ {
- for x := 0; x < n; x++ {
- img.Set(x, y, color.RGBA{uint8((x * 7) % 256), uint8((y * 13) % 256), uint8((x * y) % 256), 0xff})
- }
- }
- f, err := os.Create(path)
- if err != nil {
- t.Fatal(err)
- }
- defer f.Close()
- if err := png.Encode(f, img); err != nil {
- t.Fatal(err)
- }
-}
-
// stagingDir returns the directory the previewer actually stages into, so the
// tests exercise the real path rather than one they made up.
func stagingDir(t *testing.T) string {
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
@@ -120,7 +120,6 @@ type Module struct {
ready bool
cancel context.CancelFunc
scroll int
- contentRows int
}
type albumsMsg struct {
@@ -622,7 +621,7 @@ func (m *Module) resetAlbum() {
m.namesPath, m.namesSession = "", nil
m.log, m.outcome = nil, Outcome{}
m.err, m.status = nil, ""
- m.scroll, m.offset, m.contentRows = 0, 0, 0
+ m.scroll, m.offset = 0, 0
}
func (m Module) quit() (tea.Model, tea.Cmd) {
@@ -791,7 +790,6 @@ func (m Module) applyScroll(content string, width, height int) string {
for i, l := range lines {
lines[i] = truncateTo(l, width)
}
- m.contentRows = len(lines)
if len(lines) <= height {
return strings.Join(lines, "\n")
}