Repository navigation
fix: address bugs found in a full-codebase audit - #77
Merged
Merged
Conversation
…in language rules Treat '"' as a character literal in Rust, Scala, Haskell, F# and OCaml, honor backslash escapes in Dart, Groovy and Starlark triple-quoted strings, and stop Haskell operators such as --> and |-- from being classified as line comments.
Git allows blanks after [attr], so the name is the next token rather than a separate attribute state on a bogus pattern.
A .git file containing only 'gitdir:' made Path.GetFullPath throw instead of being ignored.
…xtraction Run the rev-parse in the hint directory so ./ and ../ resolve the way the tree prefix bookkeeping assumes, kill the cat-file process when the temp file cannot be created, and expose DeletePendingTempRoot so an interrupt can remove a partially extracted snapshot.
Math.Round used banker's rounding, so 6.25 became 6.2 while the table showed 6.3.
Drop AllowMultipleArgumentsPerToken so 'sloc -e "*.md" src' analyzes src instead of treating it as another exclude glob. Move command construction into SlocCommandFactory so parsing is testable, validate --sort, guard against a missing console when setting the output encoding, and fix the --sort/--output help text.
…aths in skip reasons Warn when no files were analyzed instead of silently passing, print the values with enough precision that 4.96% is not reported as '5.0% below 5.0%', and rewrite temporary snapshot paths embedded in skip reasons back to git paths.
…ths as errors Register cleanups for --git-hash and --compare-to extractions so an interrupt deletes the temp directory, reject --watch when stdout is redirected and keep the final table on exit, and map empty or malformed --baseline and --list-file paths to the path-error exit code instead of an unhandled exception.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
Fixes from a read-through audit of the whole codebase. Findings were prioritized and the real ones fixed; each commit covers one area and adds or updates tests.
CLI behavior
sloc -e "*.md" srcused to treatsrcas another exclude glob and silently analyze..AllowMultipleArgumentsPerTokenis removed, so each value needs its own flag (-e a -e b). Behavior change:-e a bno longer feedsbto--exclude. Command construction moved intoSlocCommandFactoryso this is covered by tests.--git-hash/--compare-to, including during extraction.--min-comment-pctwarns when no files were analyzed (still exits 0) and prints values precisely, so 4.96% is no longer reported as "5.0% below 5.0%".--watchfails with a clear error when stdout is redirected, and keeps the final table on exit.--baseline ""/--list-file ""exit with the path-error code instead of an unhandled exception.--jobs 0still means "automatic".--sortrejects undefined values; help text for--sort/--outputis corrected.Git handling
rev:./path/rev:../pathtree-ishes are resolved from the hint directory, matching the tree-prefix bookkeeping.cat-file --filtersprocess is killed if the temp file cannot be created.gitdir:in a.gitfile is treated as unusable instead of throwing.[attr]macros accept blanks between the prefix and the name.Language rules
'"'is a character literal in Rust, Scala, Haskell, F# and OCaml.-->and|--are no longer line comments.Output
LiveAggregatorusesLockfor its gate.Not changed
Reported but left alone: a backslash in file names on Linux/macOS,
.git/info/attributessupport,GitWorkTree.Findstopping at a stray.gitdirectory,--uniquededuplicating across languages, and'"'handling for Zig/Nim/Elm.Test plan
dotnet build Sloc.slnx(0 warnings, 0 errors)dotnet test Sloc.slnx(798 passed)--watchon a real terminal; classifier benchmarks were not re-run