File tree Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -114,13 +114,31 @@ function SuppressPwdParam()
114
114
115
115
if (! $testingLibraryUsage )
116
116
{
117
- Context " Bad Rule Suppression" {
118
- It " Throws a non-terminating error" {
119
- Invoke-ScriptAnalyzer - ScriptDefinition $ruleSuppressionBad - IncludeRule " PSAvoidUsingUserNameAndPassWordParams" - ErrorVariable errorRecord - ErrorAction SilentlyContinue
120
- $errorRecord.Count | Should Be 1
121
- $errorRecord.FullyQualifiedErrorId | Should match " suppression message attribute error"
122
- }
123
- }
117
+ Context " Bad Rule Suppression" {
118
+ It " Throws a non-terminating error" {
119
+ Invoke-ScriptAnalyzer - ScriptDefinition $ruleSuppressionBad - IncludeRule " PSAvoidUsingUserNameAndPassWordParams" - ErrorVariable errorRecord - ErrorAction SilentlyContinue
120
+ $errorRecord.Count | Should Be 1
121
+ $errorRecord.FullyQualifiedErrorId | Should match " suppression message attribute error"
122
+ }
123
+ }
124
+
125
+ Context " External Rule Suppression" {
126
+ $externalRuleSuppression = @'
127
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('CommunityAnalyzerRules\Measure-WriteHost','')]
128
+ param() # without the param block, powershell parser throws up!
129
+ Write-Host "write-host"
130
+ '@
131
+ It " Suppresses violation of an external ast rule" {
132
+ Invoke-ScriptAnalyzer `
133
+ - ScriptDefinition $externalRuleSuppression `
134
+ - CustomRulePath " CommunityAnalyzerRules/" `
135
+ - OutVariable ruleViolations `
136
+ - SuppressedOnly
137
+ $ruleViolations.Count | Should Be 1
138
+ }
139
+ }
140
+
141
+
124
142
}
125
143
}
126
144
You can’t perform that action at this time.
0 commit comments