-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Issue
In pomodoro/pomodoro.go:70-150, the animationTicker case (lines 73-111) and secondTicker case (lines 112-148) are 99% identical.
Problem
- Massive code duplication (~80 lines of identical logic)
- Changes to animation logic require updates in 2 places
- Hard to maintain
Solution
Extract common logic:
func renderFrame(elapsed, total time.Duration, lastPrinted int) (string, int) {
// Common rendering logic
return bar, seconds
}
// In select:
case <-animationTicker.C:
elapsedTime := time.Since(startTime)
bar, seconds := renderFrame(elapsedTime, totalDuration, lastPrintedSeconds)
if seconds != lastPrintedSeconds {
fmt.Printf("\r%s", bar)
lastPrintedSeconds = seconds
}Benefits
- Eliminates ~80 lines of code
- Easier to modify animation logic
- Single source of truth
Impact
🟢 Low - Code quality improvement
Metadata
Metadata
Assignees
Labels
No labels