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 S2583/S2589 FP: Do not raise when condition is in the body of a lock statement. #7789

Merged
merged 3 commits into from
Aug 15, 2023

Conversation

mary-georgiou-sonarsource
Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource commented Aug 14, 2023

In a multithreading context, it makes sense to check conditions twice (before and after the lock).
That's why we are ignoring what is in the lock statement body to not create a lot of noise with false positive issues.

Related to #3353

@mary-georgiou-sonarsource
Copy link
Contributor Author

@Tim-Pohlmann this is draft until peach is back up and I can see more examples for potential UTs.

@mary-georgiou-sonarsource mary-georgiou-sonarsource marked this pull request as draft August 14, 2023 13:09
@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the mary/ignore-locksstatements branch 3 times, most recently from e454226 to 5f7493a Compare August 14, 2023 13:35
Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a comment

Choose a reason for hiding this comment

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

Simple enough, LGTM! Just a few nitpicks.

@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using Microsoft.CodeAnalysis.CSharp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
using Microsoft.CodeAnalysis.CSharp;

@@ -392,15 +392,15 @@ void Method()
continue;
}

if (sb is null) // Noncompliant
if (sb is null) // Noncompliant FP
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an FP

@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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 8143cc4 into master Aug 15, 2023
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the mary/ignore-locksstatements branch August 15, 2023 12:47
@Tim-Pohlmann Tim-Pohlmann added this to the 9.8 milestone Aug 21, 2023
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.

2 participants