- SonarQube 10.0/10.1/10.6.1
- Helm
- Testing upgrade to 10.6.1
- Separate instances with scans to each for comparison
We are currently running SonarQube 10.0 deployed via Helm to an OpenShift cluster. This has been working well for over a year. We need to migrate to a separate cluster as the current will be upgraded. I am looking at upgrading at the same time to the latest 10.6.1 and have performed some test scans.
While I understand the Code as You Clean shifts the categorization, I have found a inconsistency between scans in relation to a bug that is identified by the rule java:S2583 “Conditionally executed code should be reachable”. 10.0 correctly finds the bug in a condition where the variable is always true while 10.6.1 does not. I have traced the lack of identification to version 10.1.
This can be reproduced with a very simple code block:
public class MyClass {
public static void main(String args[]) {
int dividend=10;
int divisor=2;
boolean hasError=false;
try {
DebugLog.report(dividend / divisor);
} catch (ArithmeticException e) {
DebugLog.report("Error: Cannot divide by zero.");
hasError=true;
return; // Return a default value in case of division by zero
} finally {
DebugLog.report("Finally block executed.");
}
// Code after the try-catch-finally block
if (hasError) {
DebugLog.report("Debug after the try-catch-finally block");
}
}
}
SonarQube 10.0 identifying the bug:
SonarQube 10.1 missing it:
Is this related to Clean as You Code? Am I missing anything here?
Thanks!