File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -113,4 +113,35 @@ function foo {
113
113
$violations.Count | Should Be 0
114
114
}
115
115
}
116
+
117
+ Context " When a multi-line command is given" {
118
+ It " Should find a violation if a pipleline element is not indented correctly" {
119
+ $def = @'
120
+ get-process |
121
+ where-object {$_.Name -match 'powershell'}
122
+ '@
123
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
124
+ $violations.Count | Should Be 1
125
+ }
126
+
127
+ It " Should ignore comment in the pipleline" {
128
+ $def = @'
129
+ get-process |
130
+ where-object Name -match 'powershell' | # only this is indented correctly
131
+ select Name,Id |
132
+ format-list
133
+ '@
134
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
135
+ $violations.Count | Should Be 3
136
+ }
137
+
138
+ It " Should not find a violation on a new line that follows a pipe" {
139
+ $def = @'
140
+ get-process |
141
+ where-object {$_.Name -match 'powershell'}
142
+ '@
143
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
144
+ $violations.Count | Should Be 0
145
+ }
146
+ }
116
147
}
You can’t perform that action at this time.
0 commit comments