Skip to content
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

Merged
merged 11 commits into from
May 16, 2023

Conversation

gregory-paidis-sonarsource
Copy link
Contributor

Fixes #7126

Copy link
Contributor

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

Copy link
Contributor

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@gregory-paidis-sonarsource gregory-paidis-sonarsource marked this pull request as ready for review May 16, 2023 10:02
sortedSetDerived?.Max(x => x == 42); // Compliant, comparer used
}

static void TrueNegatives()
Copy link
Contributor

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.

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage is solvable

Comment on lines +63 to +64
model.GetSymbolInfo(node).Symbol is IMethodSymbol method
&& method.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T);
Copy link
Contributor

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

Copy link
Contributor

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

96.3% 96.3% Coverage
0.0% 0.0% Duplication

@gregory-paidis-sonarsource gregory-paidis-sonarsource merged commit 9e2a97a into master May 16, 2023
@gregory-paidis-sonarsource gregory-paidis-sonarsource deleted the greg/implement-S6609 branch May 16, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants