Skip to content

Commit a517515

Browse files
committed
Remove unnecessary null checks
1 parent 4c31906 commit a517515

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ private void AnalyzeDoStatement(DoStatementSyntax node)
10211021
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken, node.WhileKeyword);
10221022
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
10231023
}
1024-
else if (node.Statement != null)
1024+
else
10251025
{
10261026
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
10271027
}
@@ -1035,7 +1035,7 @@ private void AnalyzeFixedStatement(FixedStatementSyntax node)
10351035
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken);
10361036
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
10371037
}
1038-
else if (node.Statement != null)
1038+
else
10391039
{
10401040
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
10411041
}
@@ -1049,7 +1049,7 @@ private void AnalyzeForEachStatement(ForEachStatementSyntax node)
10491049
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken);
10501050
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
10511051
}
1052-
else if (node.Statement != null)
1052+
else
10531053
{
10541054
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
10551055
}
@@ -1063,7 +1063,7 @@ private void AnalyzeForStatement(ForStatementSyntax node)
10631063
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken);
10641064
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
10651065
}
1066-
else if (node.Statement != null)
1066+
else
10671067
{
10681068
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
10691069
}
@@ -1088,7 +1088,7 @@ private void AnalyzeIfStatement(IfStatementSyntax node)
10881088
builder.Add(block.OpenBraceToken);
10891089
builder.Add(block.CloseBraceToken);
10901090
}
1091-
else if (current.Statement != null)
1091+
else
10921092
{
10931093
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(current.Statement));
10941094
}
@@ -1110,10 +1110,7 @@ private void AnalyzeIfStatement(IfStatementSyntax node)
11101110
}
11111111
else
11121112
{
1113-
if (current.Else.Statement != null)
1114-
{
1115-
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(current.Else.Statement));
1116-
}
1113+
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(current.Else.Statement));
11171114

11181115
current = null;
11191116
}
@@ -1135,7 +1132,7 @@ private void AnalyzeLockStatement(LockStatementSyntax node)
11351132
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken);
11361133
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
11371134
}
1138-
else if (node.Statement != null)
1135+
else
11391136
{
11401137
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
11411138
}
@@ -1169,10 +1166,7 @@ private void AnalyzeUsingStatement(UsingStatementSyntax node)
11691166
}
11701167
else
11711168
{
1172-
if (current.Statement != null)
1173-
{
1174-
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(current.Statement));
1175-
}
1169+
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(current.Statement));
11761170

11771171
current = null;
11781172
}
@@ -1189,7 +1183,7 @@ private void AnalyzeWhileStatement(WhileStatementSyntax node)
11891183
var tokens = ImmutableArray.Create(GetFirstTokenForAnalysis(node), block.OpenBraceToken, block.CloseBraceToken);
11901184
CheckTokens(this.context, this.compilation, this.settings, this.IndentationLevel - 1, tokens);
11911185
}
1192-
else if (node.Statement != null)
1186+
else
11931187
{
11941188
CheckElements(this.context, this.compilation, this.settings, this.IndentationLevel, ImmutableList.Create(node.Statement));
11951189
}

0 commit comments

Comments
 (0)