Skip to content

Commit fb27627

Browse files
committed
Fixed ConstantValue null check test and rule
1 parent 4bc41e9 commit fb27627

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Rules/AvoidUsingArrayList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ testAst is CommandAst cmdAst &&
107107
// Check for -TypeName parameter
108108
if (
109109
bindingResult.BoundParameters.ContainsKey("TypeName") &&
110-
bindingResult.BoundParameters["TypeName"] != null &&
110+
bindingResult.BoundParameters["TypeName"].ConstantValue != null &&
111111
arrayListName.IsMatch(bindingResult.BoundParameters["TypeName"].ConstantValue as string)
112112
)
113113
{

Tests/Rules/AvoidUsingArrayList.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Describe "AvoidArrayList" {
266266
It "Dynamic types shouldn't error" {
267267
$scriptDefinition = {
268268
$type = "System.Collections.ArrayList"
269-
New-Object -TypeName '$type'
269+
New-Object -TypeName $type
270270
}.ToString()
271271

272272
$analyzer = { Invoke-ScriptAnalyzer -ScriptDefinition $scriptDefinition -IncludeRule @($ruleName) }

0 commit comments

Comments
 (0)