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

Add -Suppress parameter #1914

Closed
iRon7 opened this issue May 12, 2023 · 3 comments
Closed

Add -Suppress parameter #1914

iRon7 opened this issue May 12, 2023 · 3 comments

Comments

@iRon7
Copy link

iRon7 commented May 12, 2023

PSScriptAnalyzer might potentially -Fix my scripts, but that is not possible for every rule (especially where it concerns false positives, such as #1472) and sometimes the "fix" is unwanted. In such a case I would like to be able to easily suppress the (remaining) violations with a command like:

Invoke-ScriptAnalyzer .\MyScript.ps1 -Suppress

(or something like: -SuppressViolations as there exist already some other -Suppress* parameters)

Where I would expect an as-narrow-as-possible suppression (using the ConditionalAttribute) for the SuppressMessageAttribute on the concerned (inner) function.

@ghost ghost added the Needs: Triage 🔍 label May 12, 2023
@iRon7 iRon7 changed the title Add -Surppress parameter Add -Suppress parameter May 12, 2023
@bergmeister
Copy link
Collaborator

Would you be willing to implement such functionality? Personally, I'd rather like to see such functionality in the VS-Code extension first on a per violation basis as a starter. There is also the trap of making things to easy where people suppress all violations without having looked at all of them in too much detail, which would strengthen my argument, that it should be easier to do that in the editor.

@iRon7
Copy link
Author

iRon7 commented May 12, 2023

@bergmeister

There is also the trap of making things to easy where people suppress all violations

You have a point there.

At the other hand, as a person who added PSScriptAnalyzer to our CICD street, it is easier to explain users to suppress rules in there script with a -Suppress switch then explaining how to implement the SuppressMessageAttribute annotation (I assume that this must count for you as well). Besides they might take the easy way here as well by e.g. suppressing all PSReviewUnusedParameter violations rather than a specific one...

@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented May 25, 2023

I agree that suppression should happen in a per rule basis which we support today, suppression is also as a part of your script, there is more information in this blog https://devblogs.microsoft.com/scripting/psscriptanalyzer-deep-dive-part-2-of-4/

This issue was closed.
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

3 participants