Repository navigation
Add documentation to all rules supporting a custom suppression target - #2225
Samuel D. Leslie (ralish) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The compatible-types guidance omits suppressible static fields and events.
1 open finding
What changed in this PR
Adds rule-specific documentation for custom SuppressMessageAttribute targets.
Changes:
- Documents global and targeted suppression syntax.
- Updates examples and suppression-guide links.
| File | Description |
|---|---|
docs/Rules/UseSingularNouns.md |
Documents function-targeted suppression. |
docs/Rules/UseSingleValueFromPipelineParameter.md |
Documents parameter-set suppression. |
docs/Rules/UseProcessBlockForPipelineCommand.md |
Documents parameter-targeted suppression. |
docs/Rules/UseDeclaredVarsMoreThanAssignments.md |
Documents variable-targeted suppression. |
docs/Rules/UseCorrectCasing.md |
Documents casing-diagnostic targets. |
docs/Rules/UseCompatibleTypes.md |
Documents type-member suppression. |
docs/Rules/ReviewUnusedParameter.md |
Documents parameter-targeted suppression. |
docs/Rules/MissingTryBlock.md |
Documents keyword-targeted suppression. |
docs/Rules/InvalidMultiDotValue.md |
Documents value-targeted suppression. |
docs/Rules/AvoidUsingPositionalParameters.md |
Documents command-targeted suppression. |
docs/Rules/AvoidUsingPlainTextForPassword.md |
Documents parameter-targeted suppression. |
docs/Rules/AvoidUsingConvertToSecureStringWithPlainText.md |
Documents command-targeted suppression. |
docs/Rules/AvoidUsingComputerNameHardcoded.md |
Documents command-targeted suppression. |
docs/Rules/AvoidUsingCmdletAliases.md |
Documents alias-targeted suppression. |
docs/Rules/AvoidUsingBrokenHashAlgorithms.md |
Documents command-targeted suppression. |
docs/Rules/AvoidUsingAllowUnencryptedAuthentication.md |
Documents command-targeted suppression. |
docs/Rules/AvoidNullOrEmptyHelpMessageAttribute.md |
Documents parameter-targeted suppression. |
docs/Rules/AvoidGlobalVars.md |
Documents scoped-variable suppression. |
docs/Rules/AvoidGlobalFunctions.md |
Documents scoped-function suppression. |
docs/Rules/AvoidDynamicallyCreatingVariableNames.md |
Documents dynamic-name suppression. |
docs/Rules/AvoidDefaultValueForMandatoryParameter.md |
Documents parameter-targeted suppression. |
docs/Rules/AvoidAssignmentToAutomaticVariable.md |
Documents variable-targeted suppression. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A subset of PSScriptAnalyzer rules support customising a suppression so that it only applies to a specific target. This is performed through the second argument to the `SuppressMessageAttribute` constructor, which is otherwise an empty string to apply the rule globally within its scope. This commit adds documentation to all rules which support customising the target of the suppression, which until now was largely undocumented.
9aefef6 to
649fb23
Compare
Christoph Bergmeister (bergmeister)
left a comment
There was a problem hiding this comment.
Thanks for trying to improve it but I don't like the duplication. I think there is a general suppression section here that we could maybe improve and optionally reference
|
Christoph Bergmeister (@bergmeister) Perhaps the leading content under each suppression section should be removed?
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('<RuleName>', '')]Removing that would condense each added suppression Markdown section to only the information unique to that rule, omitting the general "how to suppress a rule" information. The intent of the PR is to document the rules which have support for additional granularity in their suppression, as right now that's not documented anywhere. Do you have any suggestion on how best to document the information? Thanks! |
|
Yes, sorry forgot to provide link to docs where suppression is: https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/using-scriptanalyzer.md |

PR Summary
A subset of PSScriptAnalyzer rules support customising a suppression so that it only applies to a specific target. This is performed through the second argument to the
SuppressMessageAttributeconstructor, which is otherwise an empty string to apply the rule globally within its scope.This PR adds documentation to all rules which support customising the target of the suppression, which until now was largely undocumented.
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.