Repository navigation
Filter Invoke-ScriptAnalyzer results by diagnostic severity - #2268
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 3 commits into
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 3 commits into
Christoph Bergmeister (bergmeister) with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix -Severity parameter to filter diagnostics correctly
Filter Invoke-ScriptAnalyzer results by diagnostic severity
Oct 27, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The severity-filter change lacks regression tests confirming correct filtering and suppression metadata preservation under both -SuppressedOnly and -IncludeSuppressed.
1 open issue
What changed in this PR
Updates Invoke-ScriptAnalyzer -Severity to filter emitted diagnostics rather than select which rules execute, aligning behavior with the documented contract and addressing #2156.
Changes:
- Filters diagnostics by severity, including parse errors and suppressed records.
- Adds a regression test for a custom rule whose diagnostic severity differs from its configured severity.
- Clarifies the severity parameter’s source-code documentation.
| File | Description |
|---|---|
| Tests/Engine/CustomizedRule.tests.ps1 | Tests custom-rule diagnostic severity filtering. |
| Engine/ScriptAnalyzer.cs | Moves severity filtering from rule selection to diagnostic output. |
| Engine/Commands/InvokeScriptAnalyzerCommand.cs | Corrects the severity property’s documentation comment. |
Review effort: Balanced
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Contributor
Author
Added coverage for both suppression modes, severity filtering, and suppression metadata in 28e40a1. |
Christoph Bergmeister (bergmeister)
marked this pull request as ready for review
October 28, 2026 14:48
Christoph Bergmeister (bergmeister)
requested a review
from a team
as a code owner
October 28, 2026 14:48
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.

Invoke-ScriptAnalyzer -Severityfiltered rules by their configured severity instead of filtering the diagnostics those rules emitted. This could hide diagnostics whose severity differed from the rule’s severity, including errors from custom rules.-Severityto emitted diagnostic records, including parse errors and suppressed records.For example,
-Severity Errornow includes an Error diagnostic emitted by a custom rule configured as Warning:Invoke-ScriptAnalyzer-Severityfilters rules rather than diagnostics #2156