File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -484,6 +484,11 @@ private static bool IsPreviousTokenApartByWhitespace(LinkedListNode<Token> token
484
484
485
485
private static bool IsPreviousTokenApartByWhitespace ( LinkedListNode < Token > tokenNode , out bool hasRedundantWhitespace )
486
486
{
487
+ if ( tokenNode . Value . Extent . StartLineNumber != tokenNode . Previous . Value . Extent . StartLineNumber )
488
+ {
489
+ hasRedundantWhitespace = false ;
490
+ return true ;
491
+ }
487
492
var actualWhitespaceSize = tokenNode . Value . Extent . StartColumnNumber - tokenNode . Previous . Value . Extent . EndColumnNumber ;
488
493
hasRedundantWhitespace = actualWhitespaceSize - whiteSpaceSize > 0 ;
489
494
return whiteSpaceSize == actualWhitespaceSize ;
Original file line number Diff line number Diff line change @@ -45,17 +45,27 @@ Describe "UseWhitespace" {
45
45
46
46
It " Should not find violation if an open brace follows a whitespace" {
47
47
$def = ' if($true) {}'
48
- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - Be $null
48
+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
49
49
}
50
50
51
51
It " Should not find violation if an open brace follows a foreach member invocation" {
52
52
$def = ' (1..5).foreach{$_}'
53
- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - Be $null
53
+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
54
54
}
55
55
56
56
It " Should not find violation if an open brace follows a where member invocation" {
57
57
$def = ' (1..5).where{$_}'
58
- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - Be $null
58
+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
59
+ }
60
+
61
+ It " Should not find violation if an open brace is on the next line" {
62
+ $def = @'
63
+ if ($true)
64
+ {
65
+ foo
66
+ }
67
+ '@
68
+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
59
69
}
60
70
61
71
}
You can’t perform that action at this time.
0 commit comments