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(
315
315
{
316
316
var closeBraceToken = tokens [ closeBracePos ] ;
317
317
if ( ( tokens [ expectedNewLinePos ] . Kind == TokenKind . Else
318
- || tokens [ expectedNewLinePos ] . Kind == TokenKind . ElseIf ) )
318
+ || tokens [ expectedNewLinePos ] . Kind == TokenKind . ElseIf )
319
+ && ! tokensToIgnore . Contains ( closeBraceToken ) )
319
320
{
320
321
return new DiagnosticRecord (
321
322
GetError ( Strings . PlaceCloseBraceErrorShouldFollowNewLine ) ,
Original file line number Diff line number Diff line change @@ -118,6 +118,16 @@ $x = if ($true) { "blah" } else { "blah blah" }
118
118
$violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings
119
119
$violations.Count | Should Be 0
120
120
}
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
+ }
121
131
}
122
132
123
133
Context " When a close brace should be follow a new line" {
You can’t perform that action at this time.
0 commit comments