CharSequenceRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!CharSequenceRules\$).* as compiler argument.

Table of contents
  1. CharSequenceIsEmpty

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(
-      new StringBuilder("foo").length() == 0,
-      new StringBuilder("bar").length() <= 0,
-      new StringBuilder("baz").length() < 1,
-      new StringBuilder("qux").length() != 0,
-      new StringBuilder("quux").length() > 0,
-      new StringBuilder("corge").length() >= 1);
+      new StringBuilder("foo").isEmpty(),
+      new StringBuilder("bar").isEmpty(),
+      new StringBuilder("baz").isEmpty(),
+      !new StringBuilder("qux").isEmpty(),
+      !new StringBuilder("quux").isEmpty(),
+      !new StringBuilder("corge").isEmpty());
 }

Copyright © 2017-2024 Picnic Technologies BV