Skip to content

Commit 929a9d1

Browse files
committed
Fix indentation of 'else if'
1 parent 8a9a731 commit 929a9d1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1138UnitTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -888,22 +888,22 @@ void MethodName()
888888
}
889889
else if (2 == 3)
890890
{
891-
int y = 3 + 2;
891+
int y = 3 + 2;
892892
}
893893
else
894894
{
895-
int y = 3 + 2;
895+
int y = 3 + 2;
896896
}
897897
898898
if (1 == 2)
899899
return;
900900
else if (2 == 3)
901901
{
902-
int y = 3 + 2;
902+
int y = 3 + 2;
903903
}
904904
else
905905
{
906-
int y = 3 + 2;
906+
int y = 3 + 2;
907907
}
908908
909909
if (1 == 2)
@@ -914,7 +914,7 @@ void MethodName()
914914
return;
915915
else
916916
{
917-
int y = 3 + 2;
917+
int y = 3 + 2;
918918
}
919919
920920
if (1 == 2)
@@ -923,7 +923,7 @@ void MethodName()
923923
}
924924
else if (2 == 3)
925925
{
926-
int y = 3 + 2;
926+
int y = 3 + 2;
927927
}
928928
else
929929
return;

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ public override void VisitForStatement(ForStatementSyntax node)
778778

779779
public override void VisitIfStatement(IfStatementSyntax node)
780780
{
781-
using (this.AdjustIndentation(1))
781+
int adjustment = node.Parent.IsKind(SyntaxKind.ElseClause) ? 0 : 1;
782+
using (this.AdjustIndentation(adjustment))
782783
{
783784
this.AnalyzeIfStatement(node);
784785
base.VisitIfStatement(node);

0 commit comments

Comments
 (0)