CharSequenceRules
SUGGESTION
Simplification
Suppression
Disable all rules by adding
-XepOpt:Refaster:NamePattern=^(?!CharSequenceRules\$).*as compiler argument.
Table of contents
CharSequenceIsEmpty
SUGGESTION
Simplification
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("CharSequenceIsEmpty")to the enclosing element.Disable this rule by adding
-XepOpt:Refaster:NamePattern=^(?!CharSequenceRules\$CharSequenceIsEmpty).*as compiler argument.
Samples
Shows the difference in example code before and after the Refaster rule is applied.
ImmutableSet<Boolean> testCharSequenceIsEmpty() {
return ImmutableSet.of(
- "foo".length() == 0,
- "bar".length() <= 0,
- "baz".length() < 1,
- "qux".length() != 0,
- "quux".length() > 0,
- "corge".length() >= 1);
+ "foo".isEmpty(),
+ "bar".isEmpty(),
+ "baz".isEmpty(),
+ !"qux".isEmpty(),
+ !"quux".isEmpty(),
+ !"corge".isEmpty());
}