Skip to content

Commit 43c128d

Browse files
committed
Refactor and clean up SA1614
1 parent af6846b commit 43c128d

1 file changed

Lines changed: 15 additions & 30 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1614ElementParameterDocumentationMustHaveText.cs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,32 @@ public SA1614ElementParameterDocumentationMustHaveText()
5555
/// <inheritdoc/>
5656
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, IEnumerable<XmlNodeSyntax> syntaxList, params Location[] diagnosticLocations)
5757
{
58-
var xmlParameterNames = syntaxList
59-
.Where(x => string.Equals(x.GetName()?.ToString(), XmlCommentHelper.ParamXmlTag))
60-
.Select(x =>
61-
{
62-
bool isEmpty = x is XmlEmptyElementSyntax || XmlCommentHelper.IsConsideredEmpty(x);
63-
var location = x.GetLocation();
64-
65-
return new Tuple<bool, Location>(isEmpty, location);
66-
})
67-
.ToImmutableArray();
58+
foreach (var syntax in syntaxList)
59+
{
60+
bool isEmpty = syntax is XmlEmptyElementSyntax || XmlCommentHelper.IsConsideredEmpty(syntax);
6861

69-
VerifyParameters(context, xmlParameterNames, diagnosticLocations.First());
62+
if (isEmpty)
63+
{
64+
context.ReportDiagnostic(Diagnostic.Create(Descriptor, syntax.GetLocation()));
65+
}
66+
}
7067
}
7168

7269
/// <inheritdoc/>
7370
protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, XElement completeDocumentation, params Location[] diagnosticLocations)
7471
{
75-
var xmlParameterNames = completeDocumentation.Nodes()
72+
var xmlParamTags = completeDocumentation.Nodes()
7673
.OfType<XElement>()
77-
.Where(e => e.Name == XmlCommentHelper.ParamXmlTag)
78-
.Select(x =>
79-
{
80-
return new Tuple<bool, Location>(XmlCommentHelper.IsConsideredEmpty(x), null);
81-
})
82-
.ToImmutableArray();
74+
.Where(e => e.Name == XmlCommentHelper.ParamXmlTag);
8375

84-
VerifyParameters(context, xmlParameterNames, diagnosticLocations.First());
85-
}
86-
87-
private static void VerifyParameters(SyntaxNodeAnalysisContext context, ImmutableArray<Tuple<bool, Location>> documentationParameters, Location identifierLocation)
88-
{
89-
var index = 0;
90-
91-
foreach (var documentedParameter in documentationParameters)
76+
foreach (var paramTag in xmlParamTags)
9277
{
93-
if (documentedParameter.Item1)
78+
bool isEmpty = XmlCommentHelper.IsConsideredEmpty(paramTag);
79+
80+
if (isEmpty)
9481
{
95-
context.ReportDiagnostic(Diagnostic.Create(Descriptor, documentedParameter.Item2 ?? identifierLocation));
82+
context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocations.First()));
9683
}
97-
98-
index++;
9984
}
10085
}
10186
}

0 commit comments

Comments
 (0)