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 S4457 FP: Argument check after async code #6624

Merged
merged 8 commits into from
Jan 26, 2023

Conversation

gregory-paidis-sonarsource
Copy link
Contributor

Fixes #6449

argumentExceptionLocations.Add(node.GetLocation());
}
// "ThrowIfNull" returns void so it cannot be an argument. We can stop.
else
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this else block, the visit recursion stops for this node.
This means that for something like:

whatever.Invocation()

The whatever.Invocation syntax node is not going to keep visiting inside the whatever node, in which case if whatever contains an AwaitExpression, we will not spot it to stop the SyntaxWalker via:

public override void VisitAwaitExpression(AwaitExpressionSyntax node) => keepWalking = false;

Which produces this the FP in the testcases.

@gregory-paidis-sonarsource gregory-paidis-sonarsource changed the title S4457 False positive when argument check is after async code Repro+Fix Fix S4457 FP: Argument check after async code Jan 16, 2023
Copy link
Contributor

@csaba-sagi-sonarsource csaba-sagi-sonarsource left a comment

Choose a reason for hiding this comment

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

A few more modifications requested

@sonarcloud
Copy link

sonarcloud bot commented Jan 26, 2023

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

@sonarcloud
Copy link

sonarcloud bot commented Jan 26, 2023

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@csaba-sagi-sonarsource csaba-sagi-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!

@csaba-sagi-sonarsource csaba-sagi-sonarsource merged commit 1e71ac1 into master Jan 26, 2023
@csaba-sagi-sonarsource csaba-sagi-sonarsource deleted the greg/fix-S4457-FP branch January 26, 2023 15: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
Development

Successfully merging this pull request may close these issues.

Fix S4457 FP: When argument check is after async code
2 participants