@@ -41,8 +41,21 @@ if ($true){}
4141 $def = @'
4242if($true) {}
4343'@
44- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
45- $violations.Count | Should Be 0
44+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
45+ }
46+
47+ It " Should not find violation if an open brace follows a foreach member invocation" {
48+ $def = @'
49+ (1..5).foreach{$_}
50+ '@
51+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
52+ }
53+
54+ It " Should not find violation if an open brace follows a where member invocation" {
55+ $def = @'
56+ (1..5).where{$_}
57+ '@
58+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
4659 }
4760
4861 }
@@ -69,8 +82,7 @@ function foo($param1) {
6982
7083}
7184'@
72- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
73- $violations.Count | Should Be 0
85+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
7486 }
7587
7688 It " Should not find a violation in a param block" {
@@ -79,8 +91,7 @@ function foo() {
7991 param( )
8092}
8193'@
82- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
83- $violations.Count | Should Be 0
94+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
8495 }
8596
8697 It " Should not find a violation in a nested open paren" {
@@ -89,16 +100,14 @@ function foo($param) {
89100 ((Get-Process))
90101}
91102'@
92- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
93- $violations.Count | Should Be 0
103+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
94104 }
95105
96106 It " Should not find a violation on a method call" {
97107 $def = @'
98108$x.foo("bar")
99109'@
100- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
101- $violations.Count | Should Be 0
110+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
102111 }
103112 }
104113
@@ -148,16 +157,21 @@ $x = @"
148157"abc"
149158"@
150159'@
151- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
152- $violations.Count | Should Be 0
160+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
153161 }
154162
155163 It " Should not find violation if there are whitespaces of size 1 around an assignment operator for here string" {
156164 $def = @'
157165$x = 1
158166'@
159- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
160- $violations.Count | Should Be 0
167+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
168+ }
169+
170+ It " Should not find violation if there are no whitespaces around DotDot operator" {
171+ $def = @'
172+ 1..5
173+ '@
174+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
161175 }
162176 }
163177
@@ -181,8 +195,7 @@ $x = @(1,2)
181195 $def = @'
182196$x = @(1, 2)
183197'@
184- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
185- $violations.Count | Should Be 0
198+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
186199 }
187200 }
188201
@@ -206,8 +219,7 @@ $x = @{a=1;b=2}
206219 $def = @'
207220$x = @{a=1; b=2}
208221'@
209- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
210- $violations.Count | Should Be 0
222+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
211223 }
212224
213225 It " Should not find a violation if a new-line follows a semi-colon" {
@@ -217,16 +229,14 @@ $x = @{
217229 b=2
218230}
219231'@
220- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
221- $violations.Count | Should Be 0
232+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
222233 }
223234
224235 It " Should not find a violation if a end of input follows a semi-colon" {
225236 $def = @'
226237$x = "abc";
227238'@
228- $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
229- $violations.Count | Should Be 0
239+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
230240 }
231241
232242
0 commit comments