S2583 FP: When using nullable boolean in if-elseif-else. #4755
Labels
Area: C#
C# rules related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
Description
used SonarQube version: 8.9.1
A nullable boolean can have 3 values (true, false, null).
When using "if", "else if" and "else" to write conditions for all 3 cases, S2583 shows a false positive.
Repro steps
Write this code:
Our code:
![Bildschirmfoto 2021-08-03 um 13 53 56](https://user-images.githubusercontent.com/21332313/128010935-e674e8ef-6582-4539-bb2b-fa447b49afb6.png)
Expected behavior
It's not a bug.
"b == false" is not underlined red.
There is no description "Change this condition so that it does not always evaluate to 'true'; some subsequent code is never executed." because it is wrong.
Actual behavior
It underlines "b == false" red with the description "Change this condition so that it does not always evaluate to 'true'; some subsequent code is never executed."
The else part has a red background because SonarDotnet thinks, it will never be executed.
Related information
The text was updated successfully, but these errors were encountered: