Skip to content

feat(fetcher): add code_todos - #114

Merged
unhappychoice merged 4 commits into
mainfrom
feat/project-todo-in-code
Apr 25, 2026
Merged

unhappychoice merged 4 commits into
mainfrom
feat/project-todo-in-code

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Greps tracked source files for TODO / FIXME markers via gix index, so .gitignore-d build artefacts and untracked files are skipped automatically — fits the per-directory killer feature angle (different repos, different unfinished work surfaced).
  • Multi-shape: Text ("12 TODOs in 5 files"), TextBlock (path:line: snippet), Entries / Bars (files ranked by hit count).
  • Options: markers (default ["TODO", "FIXME"]) and limit (default 20). Bounded by 1 MB file-size cap, 5 000 file scan cap, and 500 internal hit cap so a giant repo doesn't blow up the splash.

Ticks the project_todo_in_code box in #62.

Test plan

  • cargo test — 528 existing + 15 new (fetcher::project) passing
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • cargo xtask regenerates docs-site/.../fetchers/project/project_todo_in_code.md (gitignored)
  • Drop into a real repo with fetcher = "project_todo_in_code" configured under ./.splashboard/config.toml and confirm the four shapes render

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a TODO counter that scans tracked repository files for configured marker tokens, excluding directories like node_modules and vendor, and displays results in multiple formats: summary counts, detailed file listings with line snippets, ranked hit counts, or visual bar charts.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a new CodeTodos fetcher that scans repository files for configurable TODO markers. It counts matches in tracked files, excludes specified directories, caches results by repo identity and marker configuration, and renders output in multiple format options. Also updates test infrastructure to support the new module.

Changes

Cohort / File(s) Summary
CodeTodos Fetcher Implementation
src/fetcher/code.rs
Implements new CodeTodos struct with logic to scan git-tracked files for TODO markers with trailing colons, exclude vendor directories, apply size caps, generate cache keys via SHA256 digest of options, and render results in Text, TextBlock, Entries, or Bars formats. Includes comprehensive test coverage.
Fetcher Registry Integration
src/fetcher/mod.rs
Adds code module and registers its fetchers into the built-in registry via code::fetchers() factory function.
Test Infrastructure Updates
src/fetcher/git/mod.rs, src/fetcher/git/test_support.rs
Makes test_support module crate-visible for test use and configures test repos to ignore global git excludes by setting core.excludesfile to /dev/null.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller/Dashboard
    participant Fetcher as CodeTodos Fetcher
    participant Cache as Cache Layer
    participant Git as Git Repository
    participant Scanner as File Scanner

    Caller->>Cache: Check cached result (cache_key)
    alt Cache Hit
        Cache-->>Caller: Return cached scan data
    else Cache Miss
        Caller->>Fetcher: fetch(options)
        Fetcher->>Git: Read repo index entries
        Git-->>Fetcher: List of tracked files
        Fetcher->>Scanner: Scan eligible files (respecting size cap, binary heuristic, directory exclusions)
        Scanner->>Scanner: Match TODO markers (word boundary, trailing colon, TODO(name):)
        Scanner-->>Fetcher: Hit count, file list, per-file hits, snippets
        Fetcher->>Fetcher: Render to body shape (Text, TextBlock, Entries, or Bars)
        Fetcher->>Cache: Store result with cache_key (repo_id + options_digest)
        Cache-->>Caller: Return rendered body
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A todo-tracking rabbit hops through code,
Finds markers in the scattered abode,
Counts every TODO with crystal care,
Caches the findings, light as air! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(fetcher): add code_todos' clearly and directly summarizes the main change: adding a new code_todos fetcher module with TODO/FIXME detection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/project-todo-in-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.48753% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.65%. Comparing base (5e9ee63) to head (bdcf1d1).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/code.rs 85.35% 64 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #114      +/-   ##
==========================================
+ Coverage   77.34%   77.65%   +0.31%     
==========================================
  Files          93       94       +1     
  Lines       15787    16228     +441     
==========================================
+ Hits        12210    12602     +392     
- Misses       3577     3626      +49     
Files with missing lines Coverage Δ
src/fetcher/git/mod.rs 86.00% <ø> (+30.00%) ⬆️
src/fetcher/git/test_support.rs 98.63% <100.00%> (+0.01%) ⬆️
src/fetcher/mod.rs 81.25% <100.00%> (+0.20%) ⬆️
src/fetcher/code.rs 85.35% <85.35%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unhappychoice unhappychoice changed the title feat(fetcher): add project_todo_in_code feat(fetcher): add code_todos Apr 25, 2026
unhappychoice and others added 4 commits April 25, 2026 17:41
Greps tracked source files for TODO / FIXME markers via the gix index, so
.gitignore-d build artefacts and untracked scratch files are skipped
automatically. Multi-shape: Text summarises totals, TextBlock lists
path:line: snippet, Entries / Bars rank files by hit count. Markers and
row limit configurable; bounded by file size / file count / hit caps.

Ticks the project_todo_in_code box in #62.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two widgets pointing at this fetcher with different `markers` (or `limit`)
options would otherwise collide on the same cache slot, since the inherited
`repo_cache_key` only mixes name / repo root / shape / format. The renderer
reads the cached payload, so the second widget would silently see the first
widget's marker hits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Bare-word matching pulled in README headings, prose, and string literals
("TODO" inside `assert_eq!(label, "TODO")` etc.), inflating counts with
non-comment noise. Tighten the matcher to require `TODO:` (or the Google-
style `TODO(name):`) and reject `::` so C++ namespace paths don't match.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ude vendored dirs

`project_*` was a category mismatch — that prefix in #62 is for project-level
operational state (test coverage, bundle size, dependency alerts). A TODO
comment grep is a *code-internal* metric, so move it to a new `code_*` family
that's the right home for future siblings (`code_loc`, `code_lint`, …). The
`_in_code` suffix becomes redundant and gets dropped.

Also wire an EXCLUDED_DIRS skip-list (`node_modules`, `vendor`, `third_party`,
`target`, `dist`, `build`, `.git`) so committed-vendored trees that some
projects ship don't bleed library TODOs into the count. `.gitignore`-d trees
are still filtered out automatically by walking the index.

Test_support detaches repos from the user's `core.excludesfile` so
environment-level globs (commonly `node_modules` / `vendor`) don't make
`git add .` skip files inside test fixtures.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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