Bug not detected RSPEC-4143

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?

import java.util.HashMap;
import java.util.Map;

class DeadStoreBug {
    public static String showBug() {
        boolean condition = false;
        Map<String, String> letters = new HashMap<>();
        letters.put("a", "Apple");
        if(condition){
            for (int i = 0; i < 10; i++) {
                // Unreachable for loop inserted
            }
        }
        letters.put("a", "Boy");
        return letters.get("a");
    }
    public static boolean getCondition() {
        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: