Incorrect warning squid:S1125

sonarlint
java

(Jonathan Rosenne) #1
  • versions used (SonarLint for Eclipse 4.0.0.201810170711)
  • 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.


(Adam Gabryś) #2

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.


(Jonathan Rosenne) #3

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