Bug: Autofix of S1125 in C# is wrong and leads to bad results

  • Operating system: Microsoft Visual Studio Community 2022 (64-Bit) - Current
    Version 17.7.0
  • SonarLint plugin version:
  • Programming language you’re coding in: C#
  • Is connected mode used: No
  • Link to GitHub-Issue

we use SonarLint with StyleCop in our company. Because there are many small warning that could be autofixed on save, we use the feature “clean-code on save”.

Here is the problem:
The Autofix of S1125 is wrong. The rule and the description are definitely correct, but the autofix function is wrong. It changes if (testBool == false) to if (testBool). Screenshot are attached.

This is the fix:
Autofix should have this result:
if (!testBool)

We had some bugs because SonarLint changed it wrong and is missing the exclamation mark on negative boolean literals. Could you please fix this? We will use the rule quick then again. Thank you! :slight_smile:


After clean-code on save

Hello @urmel

I see you have also raised the issue on github. We will address the issue there, so I am closing this community thread.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.