Repository navigation
Collect suppression declarations in a single AST traversal - #15
Merged
jessehouwing merged 1 commit intoOct 8, 2026
Merged
jessehouwing merged 1 commit into
jessehouwing merged 1 commit into
Conversation
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.
PR Summary
GetRuleSuppressionwalks the entire AST separately for function, class and configuration declarations. Formatting can repeat this discovery on large module files. This collects all three declaration types with one walk, then preserves the existing function → class → configuration processing order.The regression test checks suppressions on interleaved functions and a class, while a call outside those declarations remains visible. No public API, settings or dependency changes are needed.
This contribution targets your branch for PowerShell/PSScriptAnalyzer#2206, based on
3f5bf19. It contains only the suppression change and test; the formatter indexes in PowerShell/PSScriptAnalyzer#2224 remain separate.Native builds passed for
net8andnet462. The focused suppression and formatter suites passed all 38 tests on PowerShell 7.6.6 and Windows PowerShell 5.1. Full diagnostic details matched the baseline on Locksmith (244), PSSharedGoods (308) and PSWriteHTML (857), with no rule errors. An independent read-only review found no actionable issues.On frozen merged module files, direct suppression discovery on already-parsed ASTs took less time for Locksmith, PSSharedGoods and PSWriteHTML. The separate formatter comparison against PowerShell#2206 plus PowerShell#2224 showed 12–17% lower warmed time for PSSharedGoods and 5–21% for PSWriteHTML across the two CPU cache domains; Locksmith ranged from effectively unchanged to 13% lower. These are three rotated samples per engine and workload on each domain, with fixed affinity and all samples retained. First-call results are mixed, so this does not claim a uniform whole-build speedup. Formatted output and suppression metadata match the baseline.
PR Checklist
.cs,.ps1and.psm1files have the correct copyright header