The argument of StringBuilder.append is built with +
What it finds
builder.append("x=" + x) builds a temporary string with + and then copies it into the builder. Chained calls, builder.append("x=").append(x), append each part directly.
Reported when the receiver is known to be a StringBuilder and the argument concatenates a string literal with a value that is not a constant.
From the rule's source, concat_in_append.rs.
class Report { String render(int count, String name) { StringBuilder out = new StringBuilder(); out.append("count=" + count);tx0 reports: this string is built with + before it is appended out.append("name=").append(name); out.append("a" + "b"); return out.toString(); }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:concat-in-append" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:concat-in-append] reason="..."tx0 explain tx0/java:concat-in-append shows the same in the terminal. Found a false positive? Report it.