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

Fix S3878 FP: When input array is collection expression with spread operator #8970

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

gregory-paidis-sonarsource
Copy link
Contributor

Fixes #8510


// repro for https://github.com/SonarSource/sonar-dotnet/issues/8510
_ = new MyClass(1, [a, .. array]); // Noncompliant FP
_ = new MyClass(1, [a, .. array]); // Compliant
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


_ = new MyClass4(class1, new(1, [1, .. array])); // Compliant
_ = new MyClass4([class1, new(1, [1, .. array])]); // Noncompliant, outer collection raises, despite the nested spread operator
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case is why I do expression.Elements instead of expression.DescendantNodes()

Copy link

sonarcloud bot commented Mar 21, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Mar 21, 2024

@gregory-paidis-sonarsource gregory-paidis-sonarsource marked this pull request as ready for review March 21, 2024 14:44
Copy link
Contributor

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM!

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource merged commit 8bf481c into master Mar 21, 2024
33 checks passed
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource deleted the greg/fix-S3878-FP branch March 21, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix S3878 FP: When input array is collection expression with spread operator
2 participants