I don’t know if this is fixed yet because i cannot see the ticket linked here, but a similar thing happens when implementing a generic functional interface, example using JavaFx observables:
booleanProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
// ... do something ...
}
});
On SonarQube Developer Edition Version 9.9.1, this results in “Use a primitive boolean expression here.” code smell on line if (newValue) {
.
Developer can do nothing here of course because addListener
is a JavaFx function that expects a lamda with a parameter based on the generic type of the property, which in this case is Boolean
.