相关文章推荐
行走的剪刀  ·  [C++] ...·  2 年前    · 

Hi .NET folks

We’ve all felt the pain of deadlocks so now SonarSource has a new rule for C# and VB.NET that can detect when a resource has been locked and might not get released. It’s the first rule to benefit from our new Symbolic Analysis engine and we’re pretty excited about it. It’s been enabled in the default SonarWay profile so look out for new issues and let us know if you’re finding it useful. In future releases, as more rules use the new engine, you’ll see improved accuracy and better support for the latest language features.

The rule is available in SonarCloud today and will follow in SonarQube 9.5 and SonarLint soon.

That is a nice addition. It might be worth to add another rule in this erea:

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

As proposed by @Corniel here: https://community.sonarsource.com/t/new-rule-for-c