You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81Lines changed: 81 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,87 @@ If you have previous version of PSScriptAnalyzer installed on your machine, you
39
39
40
40
To confirm installation: run ```Get-ScriptAnalyzerRule``` in the PowerShell console to obtain the built-in rules
41
41
42
+
Suppressing Rules
43
+
=================
44
+
45
+
You can suppress a rule by decorating a script/function or script/function parameter with .NET's [SuppressMessageAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.codeanalysis.suppressmessageattribute.aspx). `SuppressMessageAttribute`'s constructor takes two parameters: a category and a check ID. Set the `categoryID` parameter to the name of the rule you want to suppress (you may omit the `checkID` parameter):
Use the `SuppressMessageAttribute`'s `Scope` property to limit rule suppression to functions or classes within the attribute's scope. Use the value `Function` to suppress violations on all functions within the attribute's scope. Use the value `Class` to suppress violoations on all classes within the attribute's scope:
The above example demonstrates how to suppress rule violations for internal functions using the `SuppressMessageAttribute`'s `Scope` property.
84
+
85
+
You can further restrict suppression based on a function/parameter/class/variable/object's name by setting the `SuppressMessageAttribute's``Target` property to a regular expression. Any function/parameter/class/variable/object whose name matches the regular expression is skipped.
0 commit comments