-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update S2328: "GetHashCode should not reference mutable fields" should report once per method #414
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
var secondaryLocations = GetAllFirstMutableFieldsUsed(c, fieldsOfClass, identifiers) | ||
.Select(identifierSyntax => new SecondaryLocation(identifierSyntax.GetLocation(), | ||
string.Format(SecondaryMessageFormat, identifierSyntax.Identifier.Text))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Select is a bit ugly and could be extracted into a method...
{ | ||
return; | ||
} | ||
|
||
var semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); | ||
var allFieldDeclarationTasks = identifiersToFix.Select(identifier => GetFieldDeclarationSyntax(semanticModel, identifier, context.CancellationToken)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should reduce our "line too long" rule limit to 130 chars. GitHub is showing scrollbar for longer lines...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Minor comments, consider them optional.
return line; | ||
} | ||
|
||
if (match.Groups["issueType"].Value.Equals("Noncompliant")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
match.Groups["issueType"].Value == "Noncompliant"
@@ -50,7 +50,8 @@ public static bool IsObjectEquals(this IMethodSymbol methodSymbol) | |||
|
|||
public static bool IsObjectGetHashCode(this IMethodSymbol methodSymbol) | |||
{ | |||
return methodSymbol.IsOverride && | |||
return methodSymbol != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. We should do it for all other methods in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalb-sonar Yes I think so too but this refactoring doesn't belong to this PR that's why I haven't done it yet.
Fix #346.