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 S3415 FP/FN: Support named arguments #6630

Closed
cristian-ambrosini-sonarsource opened this issue Jan 13, 2023 · 1 comment · Fixed by #6759
Closed

Fix S3415 FP/FN: Support named arguments #6630

cristian-ambrosini-sonarsource opened this issue Jan 13, 2023 · 1 comment · Fixed by #6759
Assignees
Labels
Area: C# C# rules related issues. Type: False Negative Rule is NOT triggered when it should be. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
Milestone

Comments

@cristian-ambrosini-sonarsource
Copy link
Contributor

cristian-ambrosini-sonarsource commented Jan 13, 2023

Description

S3415 doesn't support named arguments and considers only the positions of those, resulting in the following FN/FP:

var str = "";
Assert.AreEqual(actual: "", expected: str); // FN
Assert.AreEqual(expected: "", actual: str); // Compliant
Assert.AreEqual(actual: str, expected: ""); // Noncompliant FP
Assert.AreEqual(expected: str, actual: ""); // Noncompliant

The rule only considers literals but constant values should be checked as well:

var str = "";
Assert.AreEqual(str, "A" + "B");   // FN
Assert.AreEqual(str, ("AB"));      // FN
Assert.AreEqual(str, constString); // FN
Assert.AreEqual(someInt, -1);      // FN
@martin-strecker-sonarsource
Copy link
Contributor

The issue should be solved by using

@github-actions github-actions bot moved this from To do to Review in progress in Best Kanban Feb 20, 2023
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Feb 20, 2023
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Feb 22, 2023
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Feb 22, 2023
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Feb 24, 2023
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Feb 24, 2023
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Feb 24, 2023
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Feb 27, 2023
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Feb 28, 2023
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Feb 28, 2023
@github-actions github-actions bot moved this from Review approved to Review in progress in Best Kanban Mar 1, 2023
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Mar 6, 2023
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Mar 6, 2023
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Mar 6, 2023
Best Kanban automation moved this from Review approved to Validate Peach Mar 8, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource added this to the 8.55 milestone Mar 17, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource moved this from Validate Peach to Done in Best Kanban Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Negative Rule is NOT triggered when it should be. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
Best Kanban
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants