-
Notifications
You must be signed in to change notification settings - Fork 395
Adding documentation about suppressing rule violations. #274
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
Conversation
Hi @splatteredbits, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@splatteredbits, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
) | ||
|
||
|
||
You can also suppress a rule for an entire class using `Class` as the value of the `Scope` property: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually do this by simply decorating the class with the SuppressMessageAttribute (the scope is unnecessary in this case). A case where the use of scope is more meaningful is if you want to suppress a rule for all the classes within a script, then you can decorate the script with a SuppressMessageAttribute with the Scope as Class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the scope reflects the kind of objects in the scope where the suppress
attribute is? So a scope of "function" would apply to all functions in the
scope of the attribute?
On Mon, Jul 13, 2015 at 3:40 PM, Quoc Truong [email protected]
wrote:
In README.md
#274 (comment)
:
- {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "b")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "a")]
param([string]$a, [int]$b)
{
}
- }
+To suppress a rule for an entire function/script, decorate the
param
block of the script/function and set theSuppressMessageAttribute's
Scope
property toFunction
:
+
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")]
- param(
- )
+You can also suppress a rule for an entire class using
Class
as the value of theScope
property:You can actually do this by simply decorating the class with the
SuppressMessageAttribute (the scope is unnecessary in this case). A case
where the use of scope is more meaningful is if you want to suppress a rule
for all the classes within a script, then you can decorate the script with
a SuppressMessageAttribute with the Scope as Class.—
Reply to this email directly or view it on GitHub
https://github.com/PowerShell/PSScriptAnalyzer/pull/274/files#r34520293.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
On Mon, Jul 13, 2015 at 3:45 PM, Quoc Truong [email protected]
wrote:
In README.md
#274 (comment)
:
- {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "b")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "a")]
param([string]$a, [int]$b)
{
}
- }
+To suppress a rule for an entire function/script, decorate the
param
block of the script/function and set theSuppressMessageAttribute's
Scope
property toFunction
:
+
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")]
- param(
- )
+You can also suppress a rule for an entire class using
Class
as the value of theScope
property:Yes that is correct.
—
Reply to this email directly or view it on GitHub
https://github.com/PowerShell/PSScriptAnalyzer/pull/274/files#r34520695.
|
||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")] | ||
param( | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This param is not attached to any function or script. You can look at https://github.com/PowerShell/PSScriptAnalyzer/blob/master/Tests/Engine/RuleSuppression.ps1 for an example of a param block of a function, script or class. Thanks!
Merging the PR. Changes look good.Thanks Aaron. |
Adding documentation about suppressing rule violations.
No description provided.