@@ -9,6 +9,7 @@ if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage)
9
9
$sa = Get-Command Invoke-ScriptAnalyzer
10
10
$directory = Split-Path - Parent $MyInvocation.MyCommand.Path
11
11
$singularNouns = " PSUseSingularNouns"
12
+ $approvedVerb = " PSUseApprovedVerbs"
12
13
$rules = Get-ScriptAnalyzerRule - Name ($singularNouns , " PSUseApprovedVerbs" )
13
14
$avoidRules = Get-ScriptAnalyzerRule - Name " PSAvoid*"
14
15
$useRules = " PSUse*"
@@ -242,13 +243,19 @@ Describe "Test ExcludeRule" {
242
243
Describe " Test IncludeRule" {
243
244
Context " When used correctly" {
244
245
It " includes 1 rule" {
245
- $violations = Invoke-ScriptAnalyzer $directory \..\Rules\BadCmdlet.ps1 - IncludeRule $singularNouns | Where-Object {$_.RuleName -eq $singularNouns }
246
+ $violations = Invoke-ScriptAnalyzer $directory \..\Rules\BadCmdlet.ps1 - IncludeRule $approvedVerb | Where-Object {$_.RuleName -eq $approvedVerb }
246
247
$violations.Count | Should Be 1
247
248
}
248
249
249
- It " includes 2 rules" {
250
+ It " includes the given rules" {
251
+ # CoreCLR version of PSScriptAnalyzer does not contain PSUseSingularNouns rule
252
+ $expectedNumViolations = 2
253
+ if ((Test-PSEditionCoreCLR ))
254
+ {
255
+ $expectedNumViolations = 1
256
+ }
250
257
$violations = Invoke-ScriptAnalyzer $directory \..\Rules\BadCmdlet.ps1 - IncludeRule $rules
251
- $violations.Count | Should Be 2
258
+ $violations.Count | Should Be $expectedNumViolations
252
259
}
253
260
}
254
261
@@ -266,14 +273,20 @@ Describe "Test IncludeRule" {
266
273
}
267
274
268
275
it " includes 2 wildcardrules" {
276
+ # CoreCLR version of PSScriptAnalyzer does not contain PSUseSingularNouns rule
277
+ $expectedNumViolations = 4
278
+ if ((Test-PSEditionCoreCLR ))
279
+ {
280
+ $expectedNumViolations = 3
281
+ }
269
282
$includeWildcard = Invoke-ScriptAnalyzer $directory \..\Rules\BadCmdlet.ps1 - IncludeRule $avoidRules
270
283
$includeWildcard += Invoke-ScriptAnalyzer $directory \..\Rules\BadCmdlet.ps1 - IncludeRule $useRules
271
- $includeWildcard.Count | Should be 4
284
+ $includeWildcard.Count | Should be $expectedNumViolations
272
285
}
273
286
}
274
287
}
275
288
276
- Describe " Test Exclude And Include" {
289
+ Describe " Test Exclude And Include" {1
277
290
It " Exclude and Include different rules" {
278
291
$violations = Invoke-ScriptAnalyzer $directory \TestScript.ps1 - IncludeRule " PSAvoidUsingEmptyCatchBlock" - ExcludeRule " PSAvoidUsingPositionalParameters"
279
292
$violations.Count | Should be 1
0 commit comments