Skip to content

refactor: unify walkers and breakdown printers, dedup shared helpers#4

Merged
backstabslash merged 3 commits into
mainfrom
code-review-cleanup
Jun 5, 2026
Merged

refactor: unify walkers and breakdown printers, dedup shared helpers#4
backstabslash merged 3 commits into
mainfrom
code-review-cleanup

Conversation

@backstabslash

@backstabslash backstabslash commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Maintainability pass from a full-repo code review, plus one behavioral fix. Three commits, reviewable independently.

refactor: unify log/tool walkers and drop test-only shims

  • Collapse the two near-identical projects-directory walkers into a single dirWalker (walker.go) driven by a per-file callback.
  • Extract localMidnightCutoff and hasJSONType helpers, removing the cutoff and "type" byte-check duplication across parser.go/tools.go.
  • Add newParseResult/newToolResult constructors for the repeated map initialization.
  • Remove the formatFiveHourUsage and formatStatusline shims that existed only for tests; tests now call the real functions.

fix: count skills listed without a description in tool analytics

Skill-listing lines without a ": description" suffix (e.g. - optimize-tests) were skipped, so those skills never entered the available-skills set and were misreported as unused. The trimmed line is now used as the skill name when no separator is present.

refactor: collapse repeated sort+topN logic into generic sortAndTrim

Route the ~13 sort-and-truncate sites in format.go through one generic sortAndTrim helper instead of hand-rolling sort.Slice + topN guards at each call. Also consolidates the daily/monthly and project/branch breakdown printers (printPeriodBreakdown, printBreakdownGroup) and the JSON daily/monthly rows (jsonPeriodRow).

Verification

make check green (vet, gofmt, go test -race, golangci-lint, gocyclo). New tests cover the breakdown print paths (previously only exercised via the removed shims), bare skill-name parsing, and the JSON daily/monthly builders.

Consolidate the two near-identical projects-directory walkers into a
single dirWalker (walker.go) driven by a per-file callback. Extract
localMidnightCutoff and hasJSONType helpers to remove the cutoff and
"type" byte-check duplication across parser.go and tools.go, and add
newParseResult/newToolResult constructors for the repeated map init.

Collapse the daily/monthly and project/branch breakdown printers in
format.go, and remove the formatFiveHourUsage and formatStatusline
shims that existed only for tests (tests now call the real functions).
Skill-listing lines without a ": description" suffix (e.g. "- optimize-tests")
were skipped entirely, so those skills never appeared in the available-skills
set and were misreported as unused. Treat the trimmed line as the skill name
when no separator is present.
Route all 13 sort-and-truncate sites in format.go through one generic
helper instead of hand-rolling sort.Slice + topN guards at each call.
@backstabslash backstabslash force-pushed the code-review-cleanup branch from 1e3ba3b to 6ac509b Compare June 5, 2026 10:59
@backstabslash backstabslash changed the title Code-review cleanup: unify walkers, dedup helpers, fix skill-listing parse refactor: unify walkers and breakdown printers, dedup shared helpers Jun 5, 2026
@backstabslash backstabslash marked this pull request as ready for review June 5, 2026 11:00
@backstabslash backstabslash merged commit 49a980e into main Jun 5, 2026
1 check passed
@backstabslash backstabslash deleted the code-review-cleanup branch June 5, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant