File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -298,19 +298,24 @@ private bool IsPreviousTokenApartByWhitespace(LinkedListNode<Token> tokenNode)
298
298
( tokenNode . Value . Extent . StartColumnNumber - tokenNode . Previous . Value . Extent . EndColumnNumber ) ;
299
299
}
300
300
301
- private IEnumerable < DiagnosticRecord > FindOperatorViolations ( TokenOperations tokenOperations )
301
+ private bool IsPreviousTokenOnSameLineAndApartByWhitespace ( LinkedListNode < Token > tokenNode )
302
302
{
303
- Func < LinkedListNode < Token > , bool > predicate = tokenNode =>
304
- {
305
- return tokenNode . Previous != null
306
- && IsPreviousTokenOnSameLine ( tokenNode )
307
- && IsPreviousTokenApartByWhitespace ( tokenNode ) ;
308
- } ;
303
+ return IsPreviousTokenOnSameLine ( tokenNode ) && IsPreviousTokenApartByWhitespace ( tokenNode ) ;
304
+ }
309
305
306
+ private IEnumerable < DiagnosticRecord > FindOperatorViolations ( TokenOperations tokenOperations )
307
+ {
310
308
foreach ( var tokenNode in tokenOperations . GetTokenNodes ( IsOperator ) )
311
309
{
312
- var hasWhitespaceBefore = predicate ( tokenNode ) ;
313
- var hasWhitespaceAfter = predicate ( tokenNode . Next ) ;
310
+ if ( tokenNode . Previous == null
311
+ || tokenNode . Next == null
312
+ || tokenNode . Value . Kind == TokenKind . DotDot )
313
+ {
314
+ continue ;
315
+ }
316
+
317
+ var hasWhitespaceBefore = IsPreviousTokenOnSameLineAndApartByWhitespace ( tokenNode ) ;
318
+ var hasWhitespaceAfter = IsPreviousTokenOnSameLineAndApartByWhitespace ( tokenNode . Next ) ;
314
319
315
320
if ( ! hasWhitespaceAfter || ! hasWhitespaceBefore )
316
321
{
Original file line number Diff line number Diff line change @@ -173,6 +173,13 @@ $x = 1
173
173
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
174
174
$violations.Count | Should Be 0
175
175
}
176
+
177
+ It " Should not find violation if there are no whitespaces around DotDot operator" {
178
+ $def = @'
179
+ 1..5
180
+ '@
181
+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should Be $null
182
+ }
176
183
}
177
184
178
185
Context " When a comma is not followed by a space" {
You can’t perform that action at this time.
0 commit comments