SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
791 stars 228 forks source link

Improve S2219 GetTypeWithIsAssignableFromCodeFixProvider to not create double negation fixes #4633

Open andrei-epure-sonarsource opened 3 years ago

andrei-epure-sonarsource commented 3 years ago

Currently in GetTypeWithIsAssignableFrom.CSharp9.Fixed.cs we generate the following "fixed" code, which actually contains a code smell:

!(apple != null);   // should be 'apple == null'
!(f is Apple); // should be 'f is not Apple'

For the f is not Apple, we should extend the Lightup layer (and contribute to StyleCop) to be able to do it.

Keyword: NotPattern

andrei-epure-sonarsource commented 3 years ago

Could be related to improving the C# syntax equivalence checker (internal trello card). Also created a separate trello card.

andrei-epure-sonarsource commented 3 years ago

cc @csaba-sagi-sonarsource