File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,48 @@ function MyFunc2() {
5858 Should - Be 0
5959 }
6060
61+ It " does not flag global variable" {
62+ Invoke-ScriptAnalyzer - ScriptDefinition ' $global:x=$null' - IncludeRule $violationName | `
63+ Get-Count | `
64+ Should - Be 0
65+ }
66+
67+ It " does not flag global variable in block" {
68+ Invoke-ScriptAnalyzer - ScriptDefinition ' $global:x=$null;{$global:x=$null}' - IncludeRule $violationName | `
69+ Get-Count | `
70+ Should - Be 0
71+ }
72+
73+ It " does not flag env variable" {
74+ Invoke-ScriptAnalyzer - ScriptDefinition ' $env:x=$null' - IncludeRule $violationName | `
75+ Get-Count | `
76+ Should - Be 0
77+ }
78+
79+ It " does not flag env variable in block" {
80+ Invoke-ScriptAnalyzer - ScriptDefinition ' $env:x=$null;{$env:x=$null}' - IncludeRule $violationName | `
81+ Get-Count | `
82+ Should - Be 0
83+ }
84+
85+ It " does not flag script variable" {
86+ Invoke-ScriptAnalyzer - ScriptDefinition ' $script:x=$null' - IncludeRule $violationName | `
87+ Get-Count | `
88+ Should - Be 0
89+ }
90+
91+ It " does not flag script variable in block" {
92+ Invoke-ScriptAnalyzer - ScriptDefinition ' $script:x=$null;{$script:x=$null}' - IncludeRule $violationName | `
93+ Get-Count | `
94+ Should - Be 0
95+ }
96+
97+ It " flags private variable" {
98+ Invoke-ScriptAnalyzer - ScriptDefinition ' $private:x=$null' - IncludeRule $violationName | `
99+ Get-Count | `
100+ Should - Be 1
101+ }
102+
61103 It " flags a variable that is defined twice but never used" {
62104 Invoke-ScriptAnalyzer - ScriptDefinition ' $myvar=1;$myvar=2' - IncludeRule $violationName | `
63105 Get-Count | `
You can’t perform that action at this time.
0 commit comments