Bug not detected RSPEC-2637

Hi Sonarqube Team,

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

import javax.annotation.Nonnull;
class BugDemo {
    @Nonnull
    private String primary; 
    private String secondary;
    public BugDemo(String color) {
        if (color != null) {
            secondary = null;
        }
        primary = color; 
    }
    public BugDemo() { 
     
    }
    @Nonnull
    public String indirectMix() {
        String mix = null;
        return mix; 
    }
    public void showBug(String color) {
        BugDemo instance1 = new BugDemo(color);
        BugDemo instance2 = new BugDemo();
        String result = instance1.indirectMix();
        System.out.println("Result from indirectMix: " + result);
    }
}

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: