Skip to content

Commit 6a77fb6

Browse files
committed
Fix for - Invoke-ScriptAnalyzer -IncludeRule no longer takes RuleInfo objects
1 parent aa469df commit 6a77fb6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Engine/Generic/RuleInfo.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ public RuleInfo(string name, string commonName, string description, SourceType s
102102
Description = description;
103103
SourceType = sourceType;
104104
SourceName = sourceName;
105-
Severity = severity;
105+
Severity = severity;
106106
}
107+
108+
public override string ToString()
109+
{
110+
return RuleName;
111+
}
107112
}
108113
}

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage)
99
$sa = Get-Command Invoke-ScriptAnalyzer
1010
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
1111
$singularNouns = "PSUseSingularNouns"
12-
$rules = $singularNouns, "PSUseApprovedVerbs"
13-
$avoidRules = "PSAvoid*"
12+
$rules = Get-ScriptAnalyzerRule -Name ($singularNouns, "PSUseApprovedVerbs")
13+
$avoidRules = Get-ScriptAnalyzerRule -Name "PSAvoid*"
1414
$useRules = "PSUse*"
1515

1616
Describe "Test available parameters" {
@@ -218,7 +218,7 @@ Describe "Test IncludeRule" {
218218
}
219219

220220
It "includes 2 rules" {
221-
$violations = Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -IncludeRule $rules | Where-Object {$rules -contains $_.RuleName}
221+
$violations = Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -IncludeRule $rules
222222
$violations.Count | Should Be 2
223223
}
224224
}
@@ -237,7 +237,8 @@ Describe "Test IncludeRule" {
237237
}
238238

239239
it "includes 2 wildcardrules" {
240-
$includeWildcard = Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -IncludeRule $avoidRules, $useRules
240+
$includeWildcard = Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -IncludeRule $avoidRules
241+
$includeWildcard += Invoke-ScriptAnalyzer $directory\..\Rules\BadCmdlet.ps1 -IncludeRule $useRules
241242
$includeWildcard.Count | Should be 4
242243
}
243244
}

0 commit comments

Comments
 (0)