S864: False-Positive on ternary operator with lambda

The rule raises an issue for the following code:

Predicate<Object> predicate = (condition != null) ? condition : x -> true;

The rule is satisfied if parentheses are added around x -> true, but this sholdn’t be necessary. There is another report for false-positives when using method references: https://community.sonarsource.com/t/false-positive-on-squid-s864/3182

We are using SonarJava in version 5.14

Hello Oliver,

Thanks a lot for the feedback. Indeed, in such case of lambda, parenthesis should not be required.
Ticket created to handle the issue and update implementation of the rule: SONARJAVA-3264