Rule not detected RSPEC-5850

Hi Sonarqube Team,

The expected SonarQube bug (RSPEC-5850) 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?

import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.showBug();
    }

    public void showBug() {
        String regex = "^a|b|c$"; 
        regex = regex;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher("b");
        System.out.println(matcher.find());
    }
}

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: