-
Notifications
You must be signed in to change notification settings - Fork 232
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
New rule S6609: "Min/Max" properties of "Set" types should be used instead of the "Enumerable" extension methods #7202
Conversation
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/SetPropertiesInsteadOfMethods.cs
Outdated
Show resolved
Hide resolved
86df684
to
ce0cf01
Compare
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! I left a few comments
analyzers/src/SonarAnalyzer.Common/Rules/SetPropertiesInsteadOfMethodsBase.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/SetPropertiesInsteadOfMethods.cs
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/SetPropertiesInsteadOfMethods.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/Rules/SetPropertiesInsteadOfMethodsTest.cs
Outdated
Show resolved
Hide resolved
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! Please fix the tabs before merging
analyzers/tests/SonarAnalyzer.UnitTest/Rules/SetPropertiesInsteadOfMethodsTest.cs
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
sortedSetDerived?.Max(x => x == 42); // Compliant, comparer used | ||
} | ||
|
||
static void TrueNegatives() |
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 name suggests (to me) that you expect FalseNegatives to exist.
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.
Coverage is solvable
analyzers/src/SonarAnalyzer.Common/Rules/SetPropertiesInsteadOfMethodsBase.cs
Outdated
Show resolved
Hide resolved
model.GetSymbolInfo(node).Symbol is IMethodSymbol method | ||
&& method.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T); |
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.
IsExtensionOn
is null tolerant, so you don't need null check in the code. You can just directly cast it to IMethodSymbol
and call the extension to avoid the coverage issue..
If the 1st fix bumps the coverage enough, I might not do this 2nd one
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 should be coverable with some invalid code
bb429c9
to
2aa9990
Compare
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #7126