Skip to content

Commit 095767f

Browse files
author
Kapil Borle
committed
Fix ignore one-line if-else in PlaceCloseBrace rule
Whenever `IgnoreOneLineBlock` was set true, the rule would fire on the closing brace of `if` statement in a one line `if-else` block. This commit fixes that issue.
1 parent f7ed15c commit 095767f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Rules/PlaceCloseBrace.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)