Skip to content

Commit 5b19011

Browse files
move empty file check to end of check
1 parent 6994273 commit 5b19011

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1518UseLineEndingsCorrectlyAtEndOfFile.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ public override void Initialize(AnalysisContext context)
7272

7373
private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings)
7474
{
75-
if (context.Tree.IsEmpty(context.CancellationToken))
76-
{
77-
// Empty file never contain line endings.
78-
return;
79-
}
80-
8175
var endOfFileToken = context.Tree.GetRoot().GetLastToken(includeZeroWidth: true);
8276
TextSpan reportedSpan = new TextSpan(endOfFileToken.SpanStart, 0);
8377

@@ -191,6 +185,12 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop
191185
break;
192186
}
193187

188+
if (context.Tree.IsEmpty(context.CancellationToken))
189+
{
190+
// Empty files never contain line endings.
191+
return;
192+
}
193+
194194
context.ReportDiagnostic(Diagnostic.Create(descriptorToReport, Location.Create(context.Tree, reportedSpan)));
195195
}
196196
}

0 commit comments

Comments
 (0)