-
Notifications
You must be signed in to change notification settings - Fork 231
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
Fix S2583/S2589 FP: Do not raise when condition is in the body of a lock statement. #7789
Conversation
@Tim-Pohlmann this is draft until peach is back up and I can see more examples for potential UTs. |
e454226
to
5f7493a
Compare
2dbf8a3
to
1ba696f
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Microsoft.CodeAnalysis.CSharp; |
@@ -392,15 +392,15 @@ void Method() | |||
continue; | |||
} | |||
|
|||
if (sb is null) // Noncompliant | |||
if (sb is null) // Noncompliant FP |
There was a problem hiding this comment.
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
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
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