@@ -41,8 +41,21 @@ if ($true){}
41
41
$def = @'
42
42
if($true) {}
43
43
'@
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
46
59
}
47
60
48
61
}
@@ -69,8 +82,7 @@ function foo($param1) {
69
82
70
83
}
71
84
'@
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
74
86
}
75
87
76
88
It " Should not find a violation in a param block" {
@@ -79,8 +91,7 @@ function foo() {
79
91
param( )
80
92
}
81
93
'@
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
84
95
}
85
96
86
97
It " Should not find a violation in a nested open paren" {
@@ -89,16 +100,14 @@ function foo($param) {
89
100
((Get-Process))
90
101
}
91
102
'@
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
94
104
}
95
105
96
106
It " Should not find a violation on a method call" {
97
107
$def = @'
98
108
$x.foo("bar")
99
109
'@
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
102
111
}
103
112
}
104
113
@@ -148,16 +157,21 @@ $x = @"
148
157
"abc"
149
158
"@
150
159
'@
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
153
161
}
154
162
155
163
It " Should not find violation if there are whitespaces of size 1 around an assignment operator for here string" {
156
164
$def = @'
157
165
$x = 1
158
166
'@
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
161
175
}
162
176
}
163
177
@@ -181,8 +195,7 @@ $x = @(1,2)
181
195
$def = @'
182
196
$x = @(1, 2)
183
197
'@
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
186
199
}
187
200
}
188
201
@@ -206,8 +219,7 @@ $x = @{a=1;b=2}
206
219
$def = @'
207
220
$x = @{a=1; b=2}
208
221
'@
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
211
223
}
212
224
213
225
It " Should not find a violation if a new-line follows a semi-colon" {
@@ -217,16 +229,14 @@ $x = @{
217
229
b=2
218
230
}
219
231
'@
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
222
233
}
223
234
224
235
It " Should not find a violation if a end of input follows a semi-colon" {
225
236
$def = @'
226
237
$x = "abc";
227
238
'@
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
230
240
}
231
241
232
242
0 commit comments