Skip to content

perf cleanup, --compare-to, --sort CommentPct, test coverage - #53

Merged
coldhighsun merged 8 commits into
mainfrom
feature/compare-to-and-perf-cleanup
Sep 13, 2026
Merged

coldhighsun merged 8 commits into
mainfrom
feature/compare-to-and-perf-cleanup

Conversation

@coldhighsun

Copy link
Copy Markdown
Owner

Summary

  • perf: reduce redundant scanning work in DirectoryScanner/ScanTreeWalker (avoid re-stat for reparse points, only run gitignore/gitattributes/symlink checks on glob-matched files); add --sort CommentPct
  • refactor: extract shared ColumnLayout helper for Csv/Markdown renderers (no output change)
  • test: cover --watch validation (CliArgumentValidation.ValidateWatch) and the ignored-directory filter used by watch mode; restore per-file fault isolation in ScanTreeWalker's file enumeration
  • feat: add --compare-to <commit> to diff the current analysis directly against another commit/tree-ish, without checking it out or saving a --baseline JSON report first; combines with --git-hash to diff two commits directly; baseline scoping matches whichever side ("current") is scoped or not, so both sides of a diff always cover the same file set
  • chore: bump test package versions, refresh CLI screenshots
  • docs: document --compare-to and --sort CommentPct in CLAUDE.md and README (EN/CN)

Test plan

  • dotnet build Sloc.slnx — 0 warnings, 0 errors
  • dotnet test Sloc.slnx — 364/364 passing
  • Manually verified --compare-to alone, combined with --git-hash, subdirectory scoping, invalid commit-ish, and mutual-exclusivity errors against a real git history

Reuse FileInfo attributes already read during the directory-tree walk
instead of re-stat'ing each file for the symlink check, and only run
gitignore/gitattributes/symlink checks over glob-matched files instead
of every candidate. Also add CommentPct as a --sort key for the
per-language summary.
CsvRenderer and MarkdownRenderer built near-identical Health/Complexity
optional-column headers and rows independently. Move that logic into a
shared ColumnLayout helper; no output change.
… granularity

Extract --watch's mutual-exclusivity checks into a testable
CliArgumentValidation.ValidateWatch, make AnalyzeHandler.IsInIgnoredDirectory
internal for direct unit testing, and add tests for both.

Also restore per-file fault isolation in ScanTreeWalker's file enumeration:
a file's attribute-read failure now records a SkippedEntry for just that
file again, instead of aborting the whole directory (and its subtree).
…aseline

Diff the current analysis directly against another commit/tree-ish
extracted via GitSnapshotExtractor, without checking it out or saving
a --baseline JSON report first. Combines with --git-hash to diff two
commits directly.

The baseline is scoped to the same subdirectory as the analyzed path
when the current run is a normal filesystem scan, but stays unscoped
(whole repository) when combined with --git-hash, matching --git-hash's
own "path is the repo root" convention so both sides of the diff cover
the same file set.

Refactors DiffRenderer.Compute and AnalyzeHandler's --baseline format
handling into shared helpers reused by the new --compare-to path.
Hardcoded Windows-style backslash paths didn't split into segments on
Linux, since IsInIgnoredDirectory splits on the platform's own
directory separators. Build test paths with Path.Combine instead.
…parison

Path.GetRelativePath(GetFullPath(repoRoot), GetFullPath(repoPath)) broke
on macOS CI, where TMPDIR paths and git's --show-toplevel resolution
disagree about a symlink (/var/folders/... vs the real
/private/var/folders/...), so the computed prefix was never "." even
for the repo root itself, silently mis-scoping the baseline.

Replace it with `git rev-parse --show-prefix` run in the same directory,
which git resolves consistently with its own --show-toplevel regardless
of symlinks. GitSnapshot.RepoRoot is replaced with RelativePrefix.
@coldhighsun
coldhighsun merged commit 83fe63d into main Sep 13, 2026
9 checks passed
@coldhighsun
coldhighsun deleted the feature/compare-to-and-perf-cleanup branch September 13, 2026 16:37
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