perf cleanup, --compare-to, --sort CommentPct, test coverage - #53
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--sort CommentPctColumnLayouthelper for Csv/Markdown renderers (no output change)--watchvalidation (CliArgumentValidation.ValidateWatch) and the ignored-directory filter used by watch mode; restore per-file fault isolation inScanTreeWalker's file enumeration--compare-to <commit>to diff the current analysis directly against another commit/tree-ish, without checking it out or saving a--baselineJSON report first; combines with--git-hashto 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--compare-toand--sort CommentPctin CLAUDE.md and README (EN/CN)Test plan
dotnet build Sloc.slnx— 0 warnings, 0 errorsdotnet test Sloc.slnx— 364/364 passing--compare-toalone, combined with--git-hash, subdirectory scoping, invalid commit-ish, and mutual-exclusivity errors against a real git history