Repository navigation
Allow wildcards in --treat-as-* switches - #330
Merged
Merged
Conversation
The --treat-as-info/hint/warning/error switches only accepted exact analyzer codes, so a CI stage that wants every finding (or every finding from one analyzer family) to fail the build had to enumerate all codes up front. A trailing "*" wildcard is now supported: "*" matches every code and "GRA-*" matches a family. An exact code takes precedence over a pattern, so "--treat-as-error GRA-* --treat-as-warning GRA-STRING-001" escalates everything except that one code. Validation rejects the same exact code in two lists and overlapping patterns across lists (e.g. "*" and "GRA-*"). A "*" anywhere but the end is rejected with a new exit code. Logs are flushed before these early exits so the error is actually visible. Split Program.fs into focused modules (Arguments, ExitErrorCodes, SeverityMapping, Output, SarifReport, MsBuildProperties, ProjectLoading, Analysis) and pass the logger explicitly instead of a mutable global. Drop the unused mkKn and module-level logLevel. Add a FSharp.Analyzers.Cli.Tests project covering severity code parsing, matching, validation, precedence and MSBuild property expansion. Closes ionide#325
TheAngryByrd
approved these changes
Sep 10, 2026
This was referenced Sep 10, 2026
This was referenced Oct 3, 2026
This was referenced Oct 14, 2026
This was referenced Nov 16, 2026
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.
Closes #325
What
The
--treat-as-info,--treat-as-hint,--treat-as-warningand--treat-as-errorswitches now accept a trailing*wildcard next to exact codes:*matches every code,GRA-*matches every code with that prefix. Exact codes keep working unchanged.GRA-exceptGRA-STRING-001.*andGRA-*), is still rejected (exit code 16). The error now names the conflicting entries.*anywhere but the end (such asGRA-*-001) is rejected with a new exit code 23 rather than silently treated as an exact code.Refactoring
Program.fswas a single 1000+ line file with a mutable global logger. It is now split into focused modules (Arguments,ExitErrorCodes,SeverityMapping,Output,SarifReport,MsBuildProperties,ProjectLoading,Analysis), withProgram.fsleft as the orchestratingmain. The logger and the checker are passed explicitly. Two unused definitions (mkKnand a module-levellogLevel) were removed. No behaviour change intended.Tests
New
tests/FSharp.Analyzers.Cli.Testsproject (NUnit, likeOptionAnalyzer.Test) covering severity code parsing, matching, overlap detection, validation, precedence and MSBuild property expansion.Also verified manually against the
OptionAnalyzersample for the default and GitHub output formats, the SARIF report and each of the treat-as cases above.Other
.slnto.slnx.