@@ -24,15 +24,15 @@ Describe "UseWhitespace" {
24
24
}
25
25
26
26
It " Should find a violation if an open brace does not follow whitespace" {
27
- $def = @'
27
+ $def = @'
28
28
if ($true){}
29
29
'@
30
30
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
31
31
$violations.Count | Should Be 1
32
32
}
33
33
34
- It " Should find no violation if an open brace follows a whitespace" {
35
- $def = @'
34
+ It " Should not find violation if an open brace follows a whitespace" {
35
+ $def = @'
36
36
if($true) {}
37
37
'@
38
38
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
@@ -49,16 +49,16 @@ if($true) {}
49
49
$ruleConfiguration.CheckOperator = $false
50
50
}
51
51
52
- It " Should find no violation if an open brace follows a whitespace " {
53
- $def = @'
52
+ It " Should find violation in an if statement " {
53
+ $def = @'
54
54
if($true) {}
55
55
'@
56
56
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
57
57
$violations.Count | Should Be 1
58
58
}
59
59
60
- It " Should not find a violation if no whitespace is present before open paren of a function definition" {
61
- $def = @'
60
+ It " Should not find a violation in a function definition" {
61
+ $def = @'
62
62
function foo($param1) {
63
63
64
64
}
@@ -67,8 +67,8 @@ function foo($param1) {
67
67
$violations.Count | Should Be 0
68
68
}
69
69
70
- It " Should not find a violation if no whitespace is present before open paren of a param block" {
71
- $def = @'
70
+ It " Should not find a violation in a param block" {
71
+ $def = @'
72
72
function foo() {
73
73
param( )
74
74
}
@@ -77,11 +77,19 @@ function foo() {
77
77
$violations.Count | Should Be 0
78
78
}
79
79
80
- It " Should not find a violation if no whitespace is present in a nested open paren" {
81
- $def = @'
80
+ It " Should not find a violation in a nested open paren" {
81
+ $def = @'
82
82
function foo($param) {
83
83
((Get-Process))
84
84
}
85
+ '@
86
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
87
+ $violations.Count | Should Be 0
88
+ }
89
+
90
+ It " Should not find a violation on a method call" {
91
+ $def = @'
92
+ $x.foo("bar")
85
93
'@
86
94
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
87
95
$violations.Count | Should Be 0
@@ -96,39 +104,39 @@ function foo($param) {
96
104
}
97
105
98
106
It " Should find a violation if no whitespace around an assignment operator" {
99
- $def = @'
107
+ $def = @'
100
108
$x=1
101
109
'@
102
110
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
103
111
$violations.Count | Should Be 1
104
112
}
105
113
106
114
It " Should find a violation if no whitespace before an assignment operator" {
107
- $def = @'
115
+ $def = @'
108
116
$x= 1
109
117
'@
110
118
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
111
119
$violations.Count | Should Be 1
112
120
}
113
121
114
122
It " Should find a violation if no whitespace after an assignment operator" {
115
- $def = @'
123
+ $def = @'
116
124
$x =1
117
125
'@
118
126
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
119
127
$violations.Count | Should Be 1
120
128
}
121
129
122
130
It " Should find a violation if there is a whitespaces not of size 1 around an assignment operator" {
123
- $def = @'
131
+ $def = @'
124
132
$x = 1
125
133
'@
126
134
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
127
135
$violations.Count | Should Be 1
128
136
}
129
137
130
- It " Should find no violation if there are whitespaces of size 1 around an assignment operator" {
131
- $def = @'
138
+ It " Should not find violation if there are whitespaces of size 1 around an assignment operator" {
139
+ $def = @'
132
140
$x = 1
133
141
'@
134
142
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
0 commit comments