Hi Sonarqube Team,
The code below seems to contain the bug described in RSPEC-3518, however, the bug was not being detected during the scan. Any thoughts?
class DivisionByZeroExample {
public int showBug(int numerator, int denominator) {
return numerator / denominator;
}
public int showBug1(int numerator, int denominator) {
return numerator % denominator;
}
public static void main(String[] args) {
DivisionByZeroExample example = new DivisionByZeroExample();
try {
System.out.println("Result of division: " + example.showBug(1, 0));
} catch (ArithmeticException e) {
System.out.println("Caught an ArithmeticException: " + e.getMessage());
}
try {
System.out.println("Result of remainder: " + example.showBug1(1, 0));
} catch (ArithmeticException e) {
System.out.println("Caught an ArithmeticException: " + e.getMessage());
}
}
}
Sonarqube version 25.5
Lang: Java
SonarScanner version: 5.0.1.3006
Screenshot of code scan results
