Incorrect warning squid:S1125

  • versions used (SonarLint for Eclipse
  • Java 8
  • minimal code sample to reproduce:
    return (registryItem == null) ? false : registryItem.getMyDataType().isString();

Produced: Boolean literals should not be redundant (squid:S1125)

I suggest that this rule is not relevant for the conditional statement.

You can change it to:

return registryItem != null && registryItem.getMyDataType().isString();

It works the same. Sonar Scanner won’t create an issue. Finally, it is more readable.

I will do that, it bypasses the problem, but I suggest that it is a bug.