AutoRefactor
AutoRefactor copied to clipboard
New refactoring - Simplify more complex boolean expressions
Example 1
This code:
if (b) {
return someMethod();
} else {
return false;
}
Can be rewritten to:
return b && someMethod();
Example 2
This code:
if (b) {
return someMethod();
} else {
return true;
}
Can be rewritten to:
return !b || someMethod();
Variations
- with local variable declaration
- with local variable assignment
- with instance variable assignment
- no else clause
- use of boolean primitives
- use of boolean objects
- ...