PowerShell / PowerShell/PSScriptAnalyzer
Disable PSSA or supress all rules for **one** file without excluding path in settings.psd1?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
- Slack Community Chat: https://powershell.slack.com (you can sign-up at http://slack.poshcode.org/ for an invite)
- Also have a look at the
RoleDocumentationfolder for more information on each rule:
https://github.com/PowerShell/PSScriptAnalyzer/tree/development/RuleDocumentation
^ These links either isn't relevant anymore (first one, it's moved to Discord, right?), or does not work (the two others)
Say I have a script I'm just using for inspiration, I have no plans of iterating and improving it.
We can use [Diagnostics.CodeAnalysis.SuppressMessageAttribute()] to supress one rule. We can not use wildcard ( [Diagnostics.CodeAnalysis.SuppressMessageAttribute('*','')] ) to suppress all rules, I've tried.
Is it possible to disable PSSA or suppress all rules for one script/file, from inside that file? I don't want to hardcode paths in global PSSA settings.
To get PSSA and VSCode "Problems" tab to stay quiet I now have all these in top of the script:
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Used to output text with color')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseLiteralInitializerForHashtable','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')]
This is with the following Microsoft maintained script btw.:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing settings.psd1 and the existing handling of Diagnostics.CodeAnalysis.SuppressMessageAttribute, then check the RuleDocumentation folder and the reported VSCode Problems behavior. Done means a single script can disable PSScriptAnalyzer or suppress all rules from within that file without adding its path to global settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100