Rule not detected RSPEC-3065

Hi Sonarqube Team,

The expected SonarQube bug appears not to be detected in the code below, even though it’s caught in a very similar code as seen in the screenshot. Any thoughts?

class RangeChecker {

    private static final int UPPER = 20;
    private static final int LOWER = 0;

    public int doRangeCheck(int num) {  
        int result = Math.min(LOWER, num); 
        boolean shouldRun = getCondition();
        if (shouldRun) {
            result = num + 1; 
        } else {
            result = num - 1; 
        }
        return Math.max(UPPER, result);    
    }
    public int showBug(int num) {
        return doRangeCheck(num);
    }
    public static void main(String[] args) {
        RangeChecker checker = new RangeChecker();
        System.out.println(checker.showBug(12));
    }
    private boolean getCondition() {
        return false;
    }
}

Sonarqube version 25.5
Lang: Java
SonarScanner version: 5.0.1.3006

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: