Unreachable code in Java not detected


I am surprised that the rule RSPEC-2583 does not detect my unreachable statement in Java. Is this a false-negative regarding the rule, or can the rule only detect unreachable code when boolean expressions are used?

Here is an example of the false-negative in my sonar cloud project.

The project shows the following example:

int V1 = 1;

if (V1 > 2) {
    V1 = 3;

Here the statement V1 = 3 cannot be reached, but the rule RSPEC-2583 in SonarCloud does not report this.

Thanks in advance for your help!

1 Like

Hi Tim,

thank you for bringing up this issue, unfortunately, we are aware of this limitation in the symbolic execution engine (see SONARJAVA-4258) and for now, we won’t support such use cases.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.