Skip to content

Add documentation to all rules supporting a custom suppression target - #2225

Open
Samuel D. Leslie (ralish) wants to merge 1 commit into
PowerShell:mainfrom
ralish:update-rule-doc-suppressions
Open

Samuel D. Leslie (ralish) wants to merge 1 commit into
PowerShell:mainfrom
ralish:update-rule-doc-suppressions

Conversation

@ralish

Copy link
Copy Markdown

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 SuppressMessageAttribute constructor, 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/Rules/UseCompatibleTypes.md Outdated
Comment on lines +193 to +194
You can also suppress diagnostics for a specific method or property by passing the full type name
and the member name, separated by `/`, as the second argument:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in amended commit.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants