Open Luro02 opened 1 week ago
Simplifies complex boolean expressions into shorter ones that are easier to read.
Some things to be careful of:
X
X=3
java.util
List
Set
null
a == null || a == 1 || a == 2
USE_LISTING_CONTAINS
complexity
class Test { boolean isValid(char ch) { return ch == 'N' || ch == 'S' || ch == 'O' || ch == 'W' || ch == 'n' || ch == 's' || ch == 'o' || ch == 'w'; } }
Could be written as:
class Test { boolean isValid(char ch) { return List.of('N', 'S', 'O', 'W', 'n', 's', 'o', 'w').contains(ch); } }
What it does
Simplifies complex boolean expressions into shorter ones that are easier to read.
Some things to be careful of:
X
elements in the resulting list (maybeX=3
?)java.util
import in the model (so list can be used)List
, one could useSet
insteadnull
likea == null || a == 1 || a == 2
Lint Name
USE_LISTING_CONTAINS
Category
complexity
Example
Could be written as: