refactor: deduplicate engine internals, replace bubble sorts, remove dead code

Extract shared code that was duplicated across functions:
- taskJSON struct (MarshalJSON/UnmarshalJSON) to package-level type
- scanTask(scanner) helper for GetTask/GetTasks (~70 identical lines)
- monthNames map for parseMonthName/parseDayAndMonth
- applyNonDateAttribute helper for Apply/ApplyToNew
- resolveDisplayID calls replace inline loops in FormatTaskListWithFormat

Replace O(n²) bubble sorts with sort.Slice in all four report sort
functions (sortByUrgency, NewestReport, NextReport, OldestReport).

Remove dead code: formatTimeWithColor (unused, also used time.Now()
instead of timeNow()), getCurrentTimestamp (unnecessary wrapper).

Remove ~20 comments that restated the next line of code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 01:46:46 +01:00
parent a11f452d3b
commit 9973631df0
8 changed files with 122 additions and 288 deletions
-4
View File
@@ -14,20 +14,16 @@ func ParseKeyValueFormat(data string, skipComments bool) (map[string]string, err
lines := strings.Split(data, "\n")
for i, line := range lines {
// Trim whitespace
line = strings.TrimSpace(line)
// Skip empty lines
if line == "" {
continue
}
// Skip comments if requested
if skipComments && strings.HasPrefix(line, "#") {
continue
}
// Split on first ':'
parts := strings.SplitN(line, ":", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("line %d: invalid format (expected 'key:value')", i+1)