-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Enable new analyzer CA1868: 'Unnecessary call to 'Contains' for sets' and fix findings #89652
Conversation
The new analyzer CA1868: 'Unnecessary call to 'Contains' for sets' checks when an Add or Remove is guarded by Contains. This commit removes these calls to Contains.
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsSee dotnet/roslyn-analyzers#6767 and #85490.
|
@@ -483,6 +483,9 @@ dotnet_diagnostic.CA1863.severity = suggestion | |||
# CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method | |||
dotnet_diagnostic.CA1864.severity = warning | |||
|
|||
# CA1868: Unnecessary call to 'Contains' for sets | |||
dotnet_diagnostic.CA1868.severity = warning |
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.
Can you add a corresponding entry to the .test.globalconfig file? That one would be at level none.
if (!candidates.Add(candidatePart)) | ||
{ | ||
alreadyProcessed = true; |
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.
alreadyProcessed |= !candidates.Add(candidatePart);
?
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.
Thanks!
See dotnet/roslyn-analyzers#6767 and #85490.