Hi, I found a false negative in SonarQube 26.7.0 with sonar-java 8.34 when a primitive is boxed with a wrapper cast before compareTo().
Affected tool
SonarQube 26.7.0.124771; sonar-java 8.34 (build 44906)
Affected checker
SonarQube java:S1158
Minimal reproducer
class SpotbugsSonarqubeS1158AutoboxingCast {
int compare(int left, int right) {
return ((Integer) left).compareTo(right);
}
}
Reproduction command
sonar-scanner --version
sonar-scanner -Dsonar.projectKey=spotbugs-sonarqube-reproducer -Dsonar.sources=spotbugs-sonarqube-s1158-fn-autoboxing-cast.java -Dsonar.host.url="$SONAR_HOST_URL" -Dsonar.token="$SONAR_TOKEN"
Current behavior
SonarQube produces no java:S1158 diagnostic.
Expected behavior
SonarQube should report java:S1158 at line 3 because the cast boxes left only to invoke Integer.compareTo().