Inspectopedia Help

Boolean method is always inverted

Reports methods with a boolean return type that are always negated when called.

A quick-fix is provided to invert and optionally rename the method. For performance reasons, not all problematic methods may be highlighted in the editor.

Example:

class C { boolean alwaysTrue() { return true; } void f() { if (!alwaysTrue()) { return; } } boolean member = !alwaysTrue(); }
class C { boolean alwaysFalse() { return false; } void f() { if (alwaysFalse()) { return; } } boolean member = alwaysFalse(); }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.14841

Last modified: 12 March 2024