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: Lock objects should be read-only #5542

Closed
pavel-mikula-sonarsource opened this issue Apr 4, 2022 · 2 comments
Closed

New Rule: Lock objects should be read-only #5542

pavel-mikula-sonarsource opened this issue Apr 4, 2022 · 2 comments
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified.
Projects

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

As proposed by @Corniel here: https://community.sonarsource.com/t/new-rule-for-c-and-vb-net-locks-should-be-released/60951/2

Non-compliant

private object lock = new object(); // Noncompliant {{lock objects should be read-only.}}

Compliant

private readonly object lock = new object();
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Type: New Feature This hasn't been here before. Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Apr 4, 2022
@github-actions github-actions bot added this to New Feature in Backlog Apr 4, 2022
@pavel-mikula-sonarsource
Copy link
Contributor Author

To distinguish between S2933 and this: This should trigger on fields used by lock and SyncLock statements.

@csaba-sagi-sonarsource csaba-sagi-sonarsource added this to the Onboarding candidate milestone Sep 14, 2022
@github-actions github-actions bot added this to To do in Best Kanban Sep 14, 2022
@csaba-sagi-sonarsource csaba-sagi-sonarsource removed this from the Onboarding candidate milestone Sep 14, 2022
@csaba-sagi-sonarsource csaba-sagi-sonarsource removed this from To do in Best Kanban Sep 14, 2022
@gregory-paidis-sonarsource gregory-paidis-sonarsource added Type: Rule Idea Idea for a rule that has NOT been specified. and removed Type: New Feature This hasn't been here before. labels Feb 10, 2023
@antonioaversa
Copy link
Contributor

Seems to be a duplicate of #6701, implementation of https://sonarsource.github.io/rspec/#/rspec/S2445/csharp for C#

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. Area: VB.NET VB.NET rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified.
Projects
No open projects
Backlog
  
New Feature
Development

No branches or pull requests

4 participants