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

New rule S6507: Blocks should not be synchronized on local variables #6854

Merged
merged 2 commits into from Mar 6, 2023

Conversation

antonioaversa
Copy link
Contributor

@antonioaversa antonioaversa commented Mar 3, 2023

Implements new rule with "lock on local variable" check moved from S2445

To fix false positives introduced by #6701

Draft, to be merged together with RSPEC: SonarSource/rspec#1608

@github-actions github-actions bot added this to In progress in Best Kanban Mar 3, 2023
@antonioaversa antonioaversa changed the title Create rule S6507 with "lock on local variable" check moved from S2445 New rule S6507: Blocks should not be synchronized on local variables Mar 3, 2023
@antonioaversa antonioaversa added Area: C# C# rules related issues. Type: New Rule Implementation for a rule that HAS been specified. labels Mar 3, 2023
@antonioaversa antonioaversa added this to the 8.54 milestone Mar 3, 2023
@antonioaversa antonioaversa force-pushed the Antonio/S2445-move-local-variables-to-S6507 branch from 053f7a3 to dfae8e0 Compare March 3, 2023 16:11
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Mar 6, 2023
Copy link
Contributor

@zsolt-kolbay-sonarsource zsolt-kolbay-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

}
}

void ReportIssue(string message) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I'd keep this method and add the Rule as a parameter because it's still shorter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Otherwise LocalVariableRule doesn't need to be reported via format string and the full message can be in the rule (using string.Format directly there)
Not required for the release.

@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Mar 6, 2023
@antonioaversa antonioaversa marked this pull request as ready for review March 6, 2023 10:49
@antonioaversa antonioaversa force-pushed the Antonio/S2445-move-local-variables-to-S6507 branch from 441f077 to 032c6b2 Compare March 6, 2023 10:53
@sonarcloud
Copy link

sonarcloud bot commented Mar 6, 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 Mar 6, 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

@pavel-mikula-sonarsource pavel-mikula-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

<ul>
<li> <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock">Lock Statement</a> - lock statement - ensure
exclusive access to a shared resource </li>
<li> <a href="https://cwe.mitre.org/data/definitions/412">MITRE, CWE-412</a> - Unrestricted Externally Accessible Lock </li>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not relevant for this clone of the rule - can be fixed in RSPEC later, not in this release

Suggested change
<li> <a href="https://cwe.mitre.org/data/definitions/412">MITRE, CWE-412</a> - Unrestricted Externally Accessible Lock </li>

}
}

void ReportIssue(string message) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Otherwise LocalVariableRule doesn't need to be reported via format string and the full message can be in the rule (using string.Format directly there)
Not required for the release.

@antonioaversa antonioaversa merged commit 8dab911 into master Mar 6, 2023
24 checks passed
Best Kanban automation moved this from Review approved to Validate Peach Mar 6, 2023
@antonioaversa antonioaversa deleted the Antonio/S2445-move-local-variables-to-S6507 branch March 6, 2023 12:15
@antonioaversa antonioaversa moved this from Validate Peach to Done in Best Kanban Mar 6, 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: New Rule Implementation for a rule that HAS been specified.
Projects
Best Kanban
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants