Hi, I found a false negative in SonarQube 26.7.0 with sonar-java 8.34 when the first loop iteration passes index zero to a ResultSet getter.
Affected tool
SonarQube 26.7.0.124771; sonar-java 8.34 (build 44906)
Affected checker
SonarQube java:S2695
Minimal reproducer
import java.sql.ResultSet;
class SpotbugsSonarqubeS2695DerivedZeroIndex {
String first(ResultSet result) throws Exception {
for (int index = 0; index < 2; index++) return result.getString(index);
return "";
}
}
Reproduction command
sonar-scanner --version
sonar-scanner -Dsonar.projectKey=spotbugs-sonarqube-reproducer -Dsonar.sources=spotbugs-sonarqube-s2695-fn-derived-zero-index.java -Dsonar.host.url="$SONAR_HOST_URL" -Dsonar.token="$SONAR_TOKEN"
Current behavior
SonarQube produces no java:S2695 diagnostic.
Expected behavior
SonarQube should report java:S2695 at line 5 because the first call uses column index 0.