- Operating system: MacOS 14.2.1
- SonarLint plugin version: 10.3.0.77475
- Programming language you’re coding in: C# with Rider
- Is connected mode used: No
And a thorough description of the problem / question:
I am working with a codebase that was converted and uses non-short circuiting operators.
Sonarlint recommends “Use short-circuiting operators”. When I click this it inserts the extra character as expected however this is not safe as there is different precedence between this and other operators for example
The following code is contains the warning
if (startDate < systemDate &&
action == ActionType.DFS |
action == ActionType.ROOS)
The action performs this:
if (startDate < systemDate &&
action == ActionType.DFS ||
action == ActionType.ROOS)
But the expected/correct transformation that preserves the semantics is:
if (startDate < systemDate &&
(action == ActionType.DFS ||
action == ActionType.ROOS))
Note the extra parenthesis.