Skip to content

Collect suppression declarations in a single AST traversal - #15

Merged
jessehouwing merged 1 commit into
jessehouwing:mainfrom
PrzemyslawKlys:perf/suppression-declaration-scan
Oct 8, 2026
Merged

jessehouwing merged 1 commit into
jessehouwing:mainfrom
PrzemyslawKlys:perf/suppression-declaration-scan

Conversation

@PrzemyslawKlys

Copy link
Copy Markdown

PR Summary

GetRuleSuppression walks 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 net8 and net462. 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

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.

2 participants