StringBuilderRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

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

Table of contents
  1. StringBuilderRepeat

StringBuilderRepeat

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("StringBuilderRepeat") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!StringBuilderRules\$StringBuilderRepeat).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 StringBuilder testStringBuilderRepeat() {
-  return new StringBuilder().append("foo".repeat(1));
+  return new StringBuilder().repeat("foo", 1);
 }

Copyright © 2017-2026 Picnic Technologies BV