-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Issue
Multiple functions perform nearly identical task lookups across the entire task directory:
Duplicate Functions:
MarkTaskDone(task.go:106)MarkTaskInProgress(task.go:169)MarkTaskInProgressByTitle(task.go:233)IncrementPomodoroCountForActiveTask(task.go:297)
Each implements the same filepath.Walk logic with different predicates.
Refactor Opportunity
Create a generic search function:
func findTaskByPredicate(cfg config.Config, predicate func(*config.Task) bool) (*config.Task, string, error) {
// Common walk logic
// Call predicate(task) to check condition
}Then simplify existing functions:
func MarkTaskDone(cfg config.Config, taskTitle string) {
task, path, _ := findTaskByPredicate(cfg, func(t *config.Task) bool {
return strings.EqualFold(t.Title, taskTitle)
})
// ...
}Benefits
- Eliminates ~200 lines of duplicate code
- Single place to optimize search logic
- Easier maintenance
Impact
🟢 Low - Improvement only, no bug fix
Metadata
Metadata
Assignees
Labels
No labels