Bug not detected RSPEC-4275

Hi Team,

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

class BuggyClass {
  private int x;
  private int y;
  public void setX(int val) {
    while(getUnreachableCondition()) {} 
    this.y = val;
  }
  public int getY() {
    while(getUnreachableCondition()) {}
    return this.x;
  }
  public void showBug() {
    setX(5);
    System.out.println("Expected x to be 5, but got: " + x);
    System.out.println("Expected y to be 5, but got: " + getY());
  }
  private boolean getUnreachableCondition() {
    return false;
  }
}

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: