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 FP S3878: #6893 and #6894 #9395

Merged
merged 8 commits into from
Jun 20, 2024

Conversation

mary-georgiou-sonarsource
Copy link
Contributor

Fixes #6893
Fixes #6894

@mary-georgiou-sonarsource
Copy link
Contributor Author

@antonioaversa or @Tim-Pohlmann (whoever reviews) - all ITs are killed FPs.

@antonioaversa antonioaversa removed the request for review from Tim-Pohlmann June 5, 2024 10:01
Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

As discussed, the FN on all reference types is too penalizing for this rule.
We should check the actual array type at the call site, and act differently in presence of reference type.

@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the mary/fix-S3878-array-paramas branch 2 times, most recently from 2583d09 to 089156d Compare June 6, 2024 09:13
@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the mary/fix-S3878-array-paramas branch 2 times, most recently from 402882e to 7361e8c Compare June 6, 2024 12:34
@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the mary/fix-S3878-array-paramas branch 2 times, most recently from f696d63 to 7614e1b Compare June 7, 2024 14:25
@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the mary/fix-S3878-array-paramas branch from e7eda3d to 80d2ec3 Compare June 7, 2024 14:29
Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

I am a bit confused with the flow: see here.

Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

LGTM!
The new flow is easier to understand!
I left a minor comment here.

ArrayElementType(lastArgument, model) is { IsReferenceType: true } elementType
&& !elementType.Is(KnownType.System_Object)
&& parameterLookup.TryGetSyntax(param, out var arguments)
&& arguments.Count() is 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

arguments should be an ImmutableArray, which has the Length property, which is definitely O(1).
Count, however, is from LINQ and is in general O(n). While Count should have optimized code for IList implementers (several LINQ methods do), for arrays I would directly use Length.

Copy link

sonarcloud bot commented Jun 20, 2024

Copy link

sonarcloud bot commented Jun 20, 2024

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 02cdbf2 into master Jun 20, 2024
26 checks passed
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the mary/fix-S3878-array-paramas branch June 20, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants