Add quick fixes for S5411 (BoxedBooleanExpressionsCheck)

Description

Type

Replacement of tokens.

Approach

When the Boolean is used outside of an Optional, it is always possible to simply replace it with the proper comparison.
We should make sure to correctly support when the boolean is negated.
Inside an Optional could be supported as a second step, but seems like something that hardly ever occurs.

Before

if (B) { } if (!B) { } Optional.of(True()).orElse(null)

After

if (Boolean.TRUE.equals(B)) { } if (Boolean.FALSE.equals(B)) { } Optional.of(True()).orElse(null) // Not replaced

Activity

Show:

Quentin Jaquier August 30, 2021 at 12:05 PM

Reopening the ticket:
Binary expressions are not fixed correctly:

b == B // Becomes: Boolean.TRUE.equals(b == B)

It does not solve the issue...

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created July 20, 2021 at 2:52 PM
Updated October 16, 2024 at 2:09 PM
Resolved August 31, 2021 at 11:58 AM

Flag notifications