-
versions used:
- sonarqube-9.2.2.50622
- sonar-scanner-cli-4.6.2.2472-linux
-
error observed
- Hi, I found a false negative about this rule RSPEC-1862. Please refer to the minimized sample below (in
steps to reproduce
). SonarQube should have reported a warning at line 6 because theif
andelif
conditional expressions are same, but it doesn’t.
- Hi, I found a false negative about this rule RSPEC-1862. Please refer to the minimized sample below (in
-
steps to reproduce
- Detect the following case by SonarQube and Sonar-Scanner
public class Test {
public void foo(int param) {
if (param == 1)
System.out.println(1);
else if (1 == param) // should report a warning here, but no warnings
System.out.println(2);
}
}
- The conditional expressions in if and elif branch are same
- potential workaround
I think we should consider the left and right values of logical expression and leverage them to check whether conditional expressions are identical.