False positive for an if without else

Please provide

  • Operating system: Ubuntu
  • SonarLint plugin version: 7.3.0.59206
  • Programming language you’re coding in: Java
  • Is connected mode used: No

And a thorough description of the problem / question:

The following code produces a false positive:

    public static void main(String[] args) {
        if (args.length > 3) {
            foo(true);
        }
        foo(false);
    }

SonarLint reports issue java:S1126 “Replace this if-then-else statement by a single method invocation”.

This should not be issued because this is not an if-then-else statement and cannot be replaced by a single method invocation.

Hi,

Welcome to the community!

Could you upgrade to the latest SonarLint version (7.4.0.60471) and see if this is still replicable, please?

 
Thx!
Ann

Hi Ann,

Yes, I’ve just upgraded to the latest version (7.4.0.60471) and the issue still exists.

Regards,
Klitos

Hi Klitos,

Thanks for testing. I’ll flag this for the developers.

 
Ann