Adding documentation about suppressing rule violations.#274
Adding documentation about suppressing rule violations.#274raghushantha merged 2 commits intoPowerShell:masterfrom
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. |
README.md
Outdated
There was a problem hiding this comment.
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.
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 notifications@github.com
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
paramblock of the script/function and set theSuppressMessageAttribute'sScopeproperty toFunction:
+
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")]
- param(
- )
+You can also suppress a rule for an entire class using
Classas the value of theScopeproperty: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.
Fixed.
On Mon, Jul 13, 2015 at 3:45 PM, Quoc Truong notifications@github.com
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
paramblock of the script/function and set theSuppressMessageAttribute'sScopeproperty toFunction:
+
- [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Scope="Function")]
- param(
- )
+You can also suppress a rule for an entire class using
Classas the value of theScopeproperty:Yes that is correct.
—
Reply to this email directly or view it on GitHub
https://github.com/PowerShell/PSScriptAnalyzer/pull/274/files#r34520695.
There was a problem hiding this comment.
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.