File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,8 @@ private DiagnosticRecord GetViolationForBraceShouldHaveNewLineAfter(
315315 {
316316 var closeBraceToken = tokens [ closeBracePos ] ;
317317 if ( ( tokens [ expectedNewLinePos ] . Kind == TokenKind . Else
318- || tokens [ expectedNewLinePos ] . Kind == TokenKind . ElseIf ) )
318+ || tokens [ expectedNewLinePos ] . Kind == TokenKind . ElseIf )
319+ && ! tokensToIgnore . Contains ( closeBraceToken ) )
319320 {
320321 return new DiagnosticRecord (
321322 GetError ( Strings . PlaceCloseBraceErrorShouldFollowNewLine ) ,
Original file line number Diff line number Diff line change @@ -118,6 +118,16 @@ $x = if ($true) { "blah" } else { "blah blah" }
118118 $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
119119 $violations.Count | Should Be 0
120120 }
121+
122+ It " Should ignore violations for one line if statement even if NewLineAfter is true" {
123+ $def = @'
124+ $x = if ($true) { "blah" } else { "blah blah" }
125+ '@
126+ $ruleConfiguration .' IgnoreOneLineBlock' = $true
127+ $ruleConfiguration .' NewLineAfter' = $true
128+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
129+ $violations.Count | Should Be 0
130+ }
121131 }
122132
123133 Context " When a close brace should be follow a new line" {
You can’t perform that action at this time.
0 commit comments