Add CLI severity override flags: --blocker, --critical, --major, --minor, --info, --ignore#45
Draft
Add CLI severity override flags: --blocker, --critical, --major, --minor, --info, --ignore#45
Conversation
…nor, --info, --ignore) Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com> Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/7f135785-135a-41ee-a6da-3b9afeee686d
Copilot
AI
changed the title
[WIP] Add CLI options to override validation severity codes
Add CLI severity override flags: --blocker, --critical, --major, --minor, --info, --ignore
Mar 21, 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.
Adds six CLI flags to override the severity of specific validation codes or suppress them entirely, affecting both exit code behavior and SonarQube JSON report output.
New flags
Each flag accepts comma-separated codes (
SLNX011,SLNX012) or*for all codes.Wildcard + specific code priority
Two-pass parsing ensures specific codes always beat
*, regardless of flag order:Key changes
Program.cs— registers 6 new options;ParseSeverityOverridesuses two passes (wildcards first, specific codes second) so specific entries always winValidatorRunnerOptions— new optionalIReadOnlyDictionary<ValidationErrorCode, SonarRuleSeverity?> SeverityOverrides(null= ignore)ValidatorRunner— exit code now based on effective severity; only BLOCKER/CRITICAL/MAJOR cause exit 1SonarReporter— applies overrides to ruleseverityin JSON output; excluded ignored codes fromrulesandissuesValidationReporter— suppresses ignored codes from console output; adds(warning)/(info)labels for downgraded codesSonarRuleSeverity— changed topublic(required by CLI project)SonarQube report behavior
Override is reflected in the generated rule definition:
{ "id": "SLNX011", "severity": "MINOR", ... }Ignored codes are excluded from both
rulesandissuesentirely.Original prompt
Goal
Add CLI options to override the severity of specific validation codes, or suppress them entirely. This allows users to customize how codes are reported — both for exit code behaviour and for the SonarQube JSON report output.
New CLI flags
Add the following six flags to
Program.cs:Each flag accepts either:
SLNX011,SLNX012*to match all knownValidationErrorCodevalues:**wildcard — highest priority concern*must be supported on all flags. When*is provided, it applies the severity to all knownValidationErrorCodeenum values.Combining
*with specific overrides must work, and specific code overrides must always win over*:To implement this correctly, process flags in order of ascending priority: wildcard
*entries first (lowest priority), specific code entries last (highest priority). Within parsing,*should be expanded to all enum values first, then specific codes overwrite them.A simple way to guarantee specific codes win: sort inputs so
*is always processed before individual codes regardless of flag order on the CLI.Severity → exit code mapping
1?null)Only
BLOCKER,CRITICAL, andMAJORshould cause exit code1.MINORandINFOare shown in output but do not fail the build.Effect on SonarQube report
When
--sonarqube-report-fileis used together with severity override flags, the overriddenseveritymust be reflected in the generated rule definition in the JSON output:{ "id": "SLNX011", "severity": "MINOR", // ← overridden via --minor SLNX011 ... }Codes marked as
--ignoremust be excluded from both therulesandissuesarrays in the Sonar report entirely.Code changes required
ValidatorRunnerOptions.csAdd a new property:
Program.csDictionary<ValidationErrorCode, SonarRuleSeverity?>using a helperValidatorRunnerOptionsParsing helper logic:
Call order in
ParseSeverityOverrides— process*-capable flags in ascending priority so specific codes always win. One approach: process all flags once for*values first, then again for specific codes. Another approach: callParseIntofor all flags in a fixed order where*flags are expanded first and named-code flags are applied last. The simplest correct approach:SonarReporter.csSeverityOverridesdictionary (inject via method parameter or constructor)GetRuleDefinitionorWriteReportAsync, apply the override to the rule'sSeverityfield before serializationnull) from bothrulesandissuesValidatorRunner.csSeverityOverridesthrough to where exit code is determinedFileValidationResulthas errors that count toward exit1, filter out errors whose code has a severity override ofMINOR,INFO, ornull(ignore)Output / reporter
In
ValidationReporter.cs:This pull request was created from Copilot chat.
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.