File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 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
484484
485485 private static bool IsPreviousTokenApartByWhitespace ( LinkedListNode < Token > tokenNode , out bool hasRedundantWhitespace )
486486 {
487+ if ( tokenNode . Value . Extent . StartLineNumber != tokenNode . Previous . Value . Extent . StartLineNumber )
488+ {
489+ hasRedundantWhitespace = false ;
490+ return true ;
491+ }
487492 var actualWhitespaceSize = tokenNode . Value . Extent . StartColumnNumber - tokenNode . Previous . Value . Extent . EndColumnNumber ;
488493 hasRedundantWhitespace = actualWhitespaceSize - whiteSpaceSize > 0 ;
489494 return whiteSpaceSize == actualWhitespaceSize ;
Original file line number Diff line number Diff line change @@ -45,17 +45,27 @@ Describe "UseWhitespace" {
4545
4646 It " Should not find violation if an open brace follows a whitespace" {
4747 $def = ' if($true) {}'
48- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - Be $null
48+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
4949 }
5050
5151 It " Should not find violation if an open brace follows a foreach member invocation" {
5252 $def = ' (1..5).foreach{$_}'
53- Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - Be $null
53+ Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings | Should - BeNullOrEmpty
5454 }
5555
5656 It " Should not find violation if an open brace follows a where member invocation" {
5757 $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
5969 }
6070
6171 }
You can’t perform that action at this time.
0 commit comments