We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 667aea5 commit f7e4637Copy full SHA for f7e4637
Tests/Rules/UseDeclaredVarsMoreThanAssignments.tests.ps1
@@ -49,6 +49,18 @@ function MyFunc2() {
49
Get-Count | `
50
Should Be 0
51
}
52
+
53
+ It "flags a variable that is defined twice but never used" {
54
+ Invoke-ScriptAnalyzer -ScriptDefinition '$myvar=1;$myvar=2' -IncludeRule $violationName | `
55
+ Get-Count | `
56
+ Should Be 1
57
+ }
58
59
+ It "does not flag a variable that is defined twice but gets assigned to another variable and flags the other variable instead" {
60
+ $results = Invoke-ScriptAnalyzer -ScriptDefinition '$myvar=1;$myvar=2;$mySecondvar=$myvar' -IncludeRule $violationName
61
+ $results | Get-Count | Should Be 1
62
+ $results[0].Extent | Should Be '$mySecondvar'
63
64
65
66
Context "When there are no violations" {
0 commit comments