Improved rule suppression
PSSA2 should allow the suppression of rules:
- Current suppression attributes should be supported
- Comment-based suppression should also be supported and work based on token reading
- Ideally suppression should occur before rules create or emit a record to minimise overhead. This is most like easiest by making diagnostic emission use a method that can filter out diagnostics
- In particular, it may be useful to pre-process input and find excluded extents rather than each rule performing the same suppression discovery over and over
Another suppression scenario is being able to suppress groups of rules (possibly wildcarded) over a list of files (also possibly wildcarded).
Suppression should be possible directly in a script and at current-level only. What if you only want to ignore the usage of e.g. Write-Host called at the start or end of the script, but not inside the functions in the script?
Currently requires placing the code inside a unnecessary function just to suppress that one instance. Or you could add an unnecessary param() block at the beginning of the script for the suppression-attribute to work on at "root"-level, but this also enables the suppression for all functions in the script as well AFAIK. Possible to improve that behavior? Or even better, provide line-based suppression (related #849)?
@fflaten what you're talking about is what I refer to as comment-based suppression above.
Something like:
#|pssa:disable:PS/AvoidUsingWriteHost
Write-Host "Hello"
#|pssa:enable:PS/AvoidUsingWriteHost