Skip to content

Commit e3b5226

Browse files
committed
Remove unreachable code in analyzer and code fix
1 parent ae01750 commit e3b5226

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

DocumentationAnalyzers/DocumentationAnalyzers.CodeFixes/StyleRules/DOC108CodeFixProvider.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace DocumentationAnalyzers.StyleRules
55
{
66
using System.Collections.Immutable;
77
using System.Composition;
8+
using System.Diagnostics;
89
using System.Threading;
910
using System.Threading.Tasks;
1011
using DocumentationAnalyzers.Helpers;
@@ -27,10 +28,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
2728
{
2829
foreach (var diagnostic in context.Diagnostics)
2930
{
30-
if (!FixableDiagnosticIds.Contains(diagnostic.Id))
31-
{
32-
continue;
33-
}
31+
Debug.Assert(FixableDiagnosticIds.Contains(diagnostic.Id), "Assertion failed: FixableDiagnosticIds.Contains(diagnostic.Id)");
3432

3533
context.RegisterCodeFix(
3634
CodeAction.Create(
@@ -46,12 +44,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
4644
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
4745
{
4846
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
49-
var xmlEmptyElement = root.FindNode(diagnostic.Location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true) as XmlEmptyElementSyntax;
50-
if (xmlEmptyElement is null)
51-
{
52-
return document;
53-
}
54-
47+
var xmlEmptyElement = (XmlEmptyElementSyntax)root.FindNode(diagnostic.Location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
5548
return document.WithSyntaxRoot(root.RemoveNode(xmlEmptyElement, SyntaxRemoveOptions.KeepExteriorTrivia));
5649
}
5750
}

DocumentationAnalyzers/DocumentationAnalyzers/StyleRules/DOC108AvoidEmptyParagraphs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static void HandleXmlEmptyElementSyntax(SyntaxNodeAnalysisContext contex
4444
{
4545
var xmlEmptyElement = (XmlEmptyElementSyntax)context.Node;
4646
var name = xmlEmptyElement.Name;
47-
if (name is null || name.Prefix != null)
47+
if (name.Prefix != null)
4848
{
4949
return;
5050
}

0 commit comments

Comments
 (0)