Bug not detected RSPEC-3518

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

1 Like

Hello, thanks for the multiple reports.

I have created this ticket to group them up and keep track of them. We will investigate them as soon as we have the capacity for it!

Have a good day :slight_smile: