Bug not detected RSPEC-5863

Hi Sonarqube Team,

The code below seems to contain the bug described in RSPEC-5863, however, the bug was not being detected during the scan. Any thoughts?

import java.util.Objects;
class MyExample {
    private int value;
    public MyExample(int value) {
        this.value = value;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass()!= o.getClass()) return false;
        MyExample myExample = (MyExample) o;
        return value == myExample.value;
    }
    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
    public void showBug() {
        MyExample obj = new MyExample(10);
        assert obj.equals(obj);
    }
    public static void main(String[] args) {
        MyExample example = new MyExample(5);
        example.showBug();
    }
}

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: