Skip to content

fix(static): --per-file coverage for all static analyzers (rebased onto main) - #24

Merged
dmytrogajewski merged 2 commits into
mainfrom
fix/per-file-coverage-main
Jul 23, 2026
Merged

dmytrogajewski merged 2 commits into
mainfrom
fix/per-file-coverage-main

Conversation

@dmytrogajewski

Copy link
Copy Markdown
Contributor

Summary

Replaces #23. The --per-file fixes from #21 and #22 were merged into merge/rust-rewrite-into-main, but since #20 the canonical branch is main — so this branch cherry-picks the two fix commits directly onto main:

The resulting tree is content-identical to merge/rust-rewrite-into-main (empty diff) — the three CI/test commits on that branch already reached main via the #20 squash.

Test plan

  • All 15 per-file tests in cf-commands pass on this branch
  • Per-file files arrays previously verified byte-identical against the live Go oracle for all six static analyzers and the merged -a 'static/*' --per-file report

🤖 Generated with Claude Code

https://claude.ai/code/session_01YXDr64gTAFuMdZVDqWaw46

dmytrogajewski and others added 2 commits July 23, 2026 21:55
… reports (#21)

Only static/complexity threaded the --per-file flag into its JSON
builder; the imports/halstead/cohesion handlers dropped it, so their
sections never gained the per-file `files` array the reference
implementation emits (StaticService.enrichWithPerFileData over the
PerFileRetainer snapshots).

The three walks now retain per-file snapshots (imports: the file's
deduplicated import list; halstead: file-level scalars + the function
range; cohesion: the visitor report's scalars, message, and functions)
and new *_flags JSON entry points build one JSONFileEntry per analyzed
file — function-free/import-free files included — between `issues` and
`score`, in renderer.JSONFileEntry field order. handlers.rs passes the
flag on the three json dispatch arms.

Verified against the live Go reference binary on a mixed fixture
(multi-function, function-free, import-free, markdown files): the
`files` arrays are identical after the harness's set-order
canonicalization. Adds red-first unit tests per handler (tempfile dev
dependency) and fixes two trivial pre-existing clippy warnings in the
crate (nonminimal_bool in shotness_run.rs, useless_vec in
plot_sections/imports.rs).
…ones, and the multi-analyzer JSON merge (#22)

Closes the gaps left by the previous commit so --per-file now matches
the reference implementation across the whole static JSON surface:

- static/comments: the walk retains per-file snapshots (scalars, the
  per-file message, undocumented-function names); entries carry per-file
  score/status, the six key metrics, the Documented/Undocumented
  distribution, and name-sorted undocumented issues. Parse-failure files
  fold as the reference buildEmptyResult snapshot ("No comments found").
- static/composition: one entry per WALKED file (raw-file analyzer —
  non-UAST files included). The reference retains the raw classify
  report, which lacks every aggregate key the section reads, so each
  entry is the degenerate empty-report section ("No files analyzed",
  zero metrics, info score) with only file_path varying — reproduced
  byte-for-byte.
- static/clones: not PerFileModeEnabled in the reference, but
  EnrichWithPerFileData still initializes every section with an empty
  files array — the flag now adds `files: []` via a shared
  ensure_sections_files_key helper (the enrichment-initialization step).
- static_multi_json: the STATIC_JSON_VALUE_BUILDERS table is now
  flag-aware and the run's --per-file flag is threaded from lib.rs, so
  every merged section carries files (real entries for retaining
  analyzers, the initialized empty array for clones).

Verified against the live Go reference binary on a fixture with Go,
markdown, plain-text, and binary files: the files arrays are identical
(after set-order canonicalization) for all three single-analyzer runs
AND the full `-a 'static/*' --per-file` merged run. Red-first unit
tests added for each path plus the merge.

Co-authored-by: Dmitriy <dmit8815@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@dmytrogajewski
dmytrogajewski merged commit 3978b2c into main Jul 23, 2026
1 check passed
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