Skip to content

Validate CLI options, enable warnings-as-errors, and note --top truncation - #79

Merged
coldhighsun merged 5 commits into
mainfrom
fix/cli-validation-and-top-note
Oct 9, 2026
Merged

coldhighsun merged 5 commits into
mainfrom
fix/cli-validation-and-top-note

Conversation

@coldhighsun

Copy link
Copy Markdown
Owner

Summary

  • build: WarningsAsErrors=true was a no-op (the property takes a list of warning codes); use TreatWarningsAsErrors. Verified a clean Release build and a win-x64 trimmed single-file publish with no warnings.
  • fix: reject an undefined numeric --format (it silently rendered a table) and unknown --include-lang/--exclude-lang names (they produced an empty result with exit code 0). Both now exit with code 1. Other is accepted, matching --all.
  • feat: with --top, the Total row still covers every language, which looked inconsistent. Table, Markdown and Html now add a "Showing top N of M languages" note; Json records languageCount next to byLanguageTruncated; Csv stays note-free to keep fixed columns.
  • docs: correct the built-in language count (66) and document that Shell strings do not span lines.

Behavior changes

  • A misspelled language name or an undefined --format value now fails with exit code 1 instead of succeeding. Scripts relying on the old behavior are affected.
  • TreatWarningsAsErrors now applies to all projects, including the trimmed publish. NuGet audit warnings (NU1901-NU1904) would also fail the build; consider WarningsNotAsErrors for them if that is undesirable.

Test plan

  • dotnet test Sloc.slnx (820 tests passing)
  • dotnet publish -c Release -r win-x64 with no warnings, and a smoke run of the published exe

WarningsAsErrors=true was a no-op, since the property takes a list of warning codes.
…clude-lang names

An out-of-range numeric --format silently rendered a table, and a misspelled
language name produced an empty result with exit code 0. Both now fail with
exit code 1 before the analysis runs.
The package description said 44 and CLAUDE.md said 58; the registry defines 66.
The Total row covers every language, so a --top table looked inconsistent.
Table, Markdown, and Html now add a "Showing top N of M languages" note, and
Json records languageCount next to byLanguageTruncated. Csv stays note-free to
keep fixed columns.
A # line inside a multi-line string, heredoc, or awk script is counted as a
comment; spanning lines would let one unbalanced quote swallow the rest of the file.
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Sloc.Cli/Parsing/SlocCommandFactory.cs 88.23% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@coldhighsun
coldhighsun merged commit c170111 into main Oct 9, 2026
10 checks passed
@coldhighsun
coldhighsun deleted the fix/cli-validation-and-top-note branch October 9, 2026 11:40
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