Inspectopedia Help

Chained equality comparisons

Reports chained equality comparisons.

Such comparisons may be confusing: a == b == c means (a == b) == c, but possibly a == b && a == c is intended.

Example:

boolean chainedEquality(boolean a, boolean b, boolean c) { return a == b == c; }

You can use parentheses to make the comparison less confusing:

boolean chainedEquality(boolean a, boolean b, boolean c) { return (a == b) == c; }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024