Skip to content

Commit e6c5b10

Browse files
committed
Remove unnecessary handling of null location in SA1612
1 parent a123f02 commit e6c5b10

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
6868
return;
6969
}
7070

71-
var identifierLocation = identifier.Value.GetLocation();
7271
var parameterList = GetParameters(node)?.ToImmutableArray();
7372

7473
bool hasNoParameters = !parameterList?.Any() ?? false;
@@ -84,18 +83,19 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
8483
{
8584
var nameAttributeSyntax = XmlCommentHelper.GetFirstAttributeOrDefault<XmlNameAttributeSyntax>(syntax);
8685
var nameAttributeText = nameAttributeSyntax?.Identifier?.Identifier.ValueText;
87-
var location = nameAttributeSyntax?.Identifier?.Identifier.GetLocation();
8886

8987
// Make sure we ignore violations that should be reported by SA1613 instead.
9088
if (string.IsNullOrWhiteSpace(nameAttributeText))
9189
{
9290
return;
9391
}
9492

93+
var location = nameAttributeSyntax.Identifier.Identifier.GetLocation();
94+
9595
var parentParameter = parentParameters.FirstOrDefault(s => s.Identifier.ValueText == nameAttributeText);
9696
if (parentParameter == null)
9797
{
98-
context.ReportDiagnostic(Diagnostic.Create(MissingParameterDescriptor, location ?? identifierLocation, nameAttributeText));
98+
context.ReportDiagnostic(Diagnostic.Create(MissingParameterDescriptor, location, nameAttributeText));
9999
}
100100
else
101101
{
@@ -114,7 +114,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool
114114
context.ReportDiagnostic(
115115
Diagnostic.Create(
116116
OrderDescriptor,
117-
location ?? identifierLocation,
117+
location,
118118
nameAttributeText,
119119
parentParameters.IndexOf(parentParameter) + 1));
120120
}

0 commit comments

Comments
 (0)