Skip to content

Bug: S1125 code fix does not add ! when transforming x == false. #7999

@urmel9

Description

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

Hello,
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:

Before:
sonarLint_s1125-before

After clean-code on save
sonarLint_s1125-after

Metadata

Metadata

Labels

Code FixAnything related to Code Fixes

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions