-
Notifications
You must be signed in to change notification settings - Fork 223
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 S6605: Collection-specific "Exists" method should be used instead of the "Any" extension #7160
Conversation
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\Nancy\src\Nancy.Testing\ConfigurableBootstrapper.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\Nancy\src\Nancy.Testing\ConfigurableBootstrapper.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\Nancy\src\Nancy.Testing\ConfigurableBootstrapper.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\Nancy\src\Nancy.Testing\ConfigurableBootstrapper.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\Nancy\src\Nancy.ViewEngines.Spark\NancyViewFolder.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\akka.net\src\core\Akka\Actor\ActorProducerPipeline.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\akka.net\src\core\Akka\Actor\ActorProducerPipeline.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\akka.net\src\core\Akka\Event\EventBus.cs", |
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.
"id": "S6605", | ||
"message": "Collection-specific "Exists" method should be used instead of the "Any" extension.", | ||
"location": { | ||
"uri": "sources\akka.net\src\contrib\cluster\Akka.Cluster.Tools\Singleton\OldestChangedBuffer.cs", |
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.
23dcb49
to
32474cb
Compare
32474cb
to
bf4c731
Compare
analyzers/tests/SonarAnalyzer.UnitTest/Rules/ExistsInsteadOfAnyTest.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ExistsInsteadOfAny.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ExistsInsteadOfAny.vb
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.Common/Rules/ExistsInsteadOfAnyBase.cs
Outdated
Show resolved
Hide resolved
7baef50
to
d6e1da0
Compare
analyzers/src/SonarAnalyzer.Common/Rules/ExistsInsteadOfAnyBase.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.VisualBasic/Rules/ExistsInsteadOfAny.cs
Outdated
Show resolved
Hide resolved
9d7a862
to
e8c434b
Compare
d267004
to
fe23c27
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.
Looks way better, I can see the finish line!
analyzers/src/SonarAnalyzer.VisualBasic/Rules/ExistsInsteadOfAny.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ExistsInsteadOfAny.cs
Outdated
Show resolved
Hide resolved
402d777
to
8e0fccc
Compare
|
||
intList.Any(x => x.GetType() == typeof(int)); // Noncompliant | ||
intList.Any(x => x.GetType().Equals(typeof(int))); // Noncompliant FP | ||
intList.Any(x => MyIntCheck(x)); // 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.
Add this type of check but without the argument for completion sake:
intList.Any(MyIntCheck) // Noncompliant
same for string check
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! 🥇
Left a very minor comment, feel free to merge afterwards! 🤗
I think the implementation covers most of the equality scenarios, and I imagine the Contains
rule will be as much fun to implement as this one!
Congratulations!
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #7123