Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved rule suppression #1483

Open
rjmholt opened this issue May 6, 2020 · 2 comments
Open

Improved rule suppression #1483

rjmholt opened this issue May 6, 2020 · 2 comments
Milestone

Comments

@rjmholt
Copy link
Contributor

rjmholt commented May 6, 2020

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).

@ghost ghost added the Needs: Triage 🔍 label May 6, 2020
@rjmholt rjmholt added this to the 2.0 milestone May 6, 2020
@fflaten
Copy link
Contributor

fflaten commented Nov 3, 2020

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)?

@rjmholt
Copy link
Contributor Author

rjmholt commented Nov 4, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants