Skip to content

feat(fetcher): add code_largest_files for refactor-candidate hunting - #171

Merged
unhappychoice merged 1 commit into
mainfrom
feat/code-largest-files
Apr 27, 2026
Merged

unhappychoice merged 1 commit into
mainfrom
feat/code-largest-files

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds code_largest_files — ranks the largest tracked source files in the discovered git repo. Walks the gix index via the shared for_each_tracked_file helper, so untracked / .gitignore-d files plus committed-vendored trees, lockfiles, and binaries are skipped automatically.
  • Seven shapes from one read: Text (headline), TextBlock / MarkdownTextBlock / Entries / Bars (per-file ranking), NumberSeries (size distribution), Badge (refactor-candidate tier — tidy / big / bloated / monster).
  • Lands the body 5 "hotspots" slot of the upcoming project_codebase preset (feat(templates): add project_codebase preset — repo personality / analytics #164). Sub-issue: meta: fetcher roadmap - Local / System #62.

Reference page

Mirrors what https://splashboard.unhappychoice.com/reference/fetchers/code/code_largest_files will show after the docs site rebuilds.

Kind Safety Shapes
cached Safe text, text_block, markdown_text_block, entries, bars, number_series, badge

Options

Option Type Required Default Description
metric loc | bytes no loc What to rank files by: loc (text line count, binaries skipped) or bytes (raw file size). LOC suits refactor-candidate hunting; bytes suits asset-weight audits.
limit integer no 10 Cap on ranked rows (TextBlock / MarkdownTextBlock / Entries / Bars / NumberSeries). The Text headline always names just the single largest file.

Compatible renderers

Shape Renderers
text text_plain, text_ascii, animated_*
text_block list_plain, animated_*
markdown_text_block text_markdown
entries grid_table, animated_*
bars chart_bar, chart_pie, list_ranking, animated_*
number_series chart_histogram, chart_sparkline, animated_*
badge status_badge, animated_*

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (985 passed)
  • cargo run --bin splashboard -- catalog fetcher code_largest_files — all 7 shapes + options + compatible renderers listed
  • Smoke-tested locally with Text / Entries (default + metric = "bytes") / Bars (chart_bar) / Badge widget configurations

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a code analysis tool that scans your repository and identifies the largest files ranked by either file size or line count. Supports multiple visualization formats including text summaries, detailed lists, progress bars, status badges, and numeric series. Configure your preferred metric and result limits.

Ranks the largest tracked source files in the discovered git repo. Walks
the `gix` index via the shared `for_each_tracked_file` helper, so
untracked / `.gitignore`-d files plus committed-vendored trees, lockfiles,
and binaries are skipped automatically.

Seven shapes from one read:
- `Text` headlines the single biggest file (`"src/render/mod.rs (1,234 LOC)"`)
- `TextBlock` / `MarkdownTextBlock` / `Entries` / `Bars` carry the per-file ranking
- `NumberSeries` sketches the size distribution
- `Badge` flags whether the repo holds a refactor-candidate-sized file
  (`tidy` / `big` / `bloated` / `monster`) — separate health signal from
  `code_loc`'s repo-total tier

Options: `metric = "loc" | "bytes"` (LOC default suits refactor hunting;
bytes suits asset-weight audits) and `limit` (default 10).

Lands the body 5 "hotspots" slot of the upcoming `project_codebase`
preset (#164).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new CodeLargestFiles fetcher is introduced that scans tracked git repository files, ranks them by UTF-8 text line count or byte size, and renders results across multiple formats (text, lists, badges, charts). It integrates into the code fetcher registry with configurable metrics and limits.

Changes

Cohort / File(s) Summary
CodeLargestFiles Fetcher Implementation
src/fetcher/code/largest_files.rs
New fetcher struct implementing Fetcher trait with methods for file scanning, ranking by metric (LOC/bytes), multi-format rendering (Text, TextBlock, MarkdownTextBlock, Entries, Bars, NumberSeries, Badge), tier-based status mapping, option parsing, and comprehensive unit tests.
Code Fetcher Module Integration
src/fetcher/code/mod.rs
Declares largest_files submodule, re-exports CodeLargestFiles type, and registers it in the fetcher pipeline alongside existing code fetchers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A fetcher hops through tracked files with glee,
Counting lines and bytes, ranking by decree,
Multiple shapes it renders with care—
Text, bars, and badges float through the air! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.55% 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 pull request title accurately and specifically describes the main change: adding a new code_largest_files fetcher for identifying refactor-candidate files.
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/code-largest-files

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 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.53521% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.58%. Comparing base (08b8d5f) to head (bd9b4d4).
⚠️ Report is 2 commits behind head on main.

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

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
+ Coverage   78.53%   78.58%   +0.05%     
==========================================
  Files         131      132       +1     
  Lines       24889    25244     +355     
==========================================
+ Hits        19546    19839     +293     
- Misses       5343     5405      +62     
Files with missing lines Coverage Δ
src/fetcher/code/mod.rs 100.00% <100.00%> (ø)
src/fetcher/code/largest_files.rs 82.48% <82.48%> (ø)
🚀 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 merged commit d07bc4a into main Apr 27, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/code-largest-files branch April 27, 2026 05:59
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