[Java:S2589] Ignore for Boolean boxes

The following code falsely complains about “Remove this expression which always evaluates to “true””.

public void foo()
{
    Boolean b = ...;
    if ( b == Boolean.TRUE )
        doSomething();
    else if ( b == Boolean.FALSE ) // FP
        doSomethingElse();
}

‘b’ can also be null. And hence this does not always evaluate to true.

Hi Marvin,

Thanks for your feedback. It’s a FP. Created a ticket.

Kind regards,
Margarita

Hi Margarita,

thanks a lot.

Cheers
Marvin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.