A literal is turned into a string by adding it to an empty string
What it finds
"" + 42 turns a constant into text by concatenation, which reads like an accident; "42" or String.valueOf(42) says it directly.
Reported is an empty string literal joined with + to a number, character or boolean literal.
From the rule's source, empty_string_conversion.rs.
class Text { String run(int count) { String a = "" + 42;tx0 reports: adding it to String b = "" + count; String c = "a" + 42; return a + b + c; }} 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:empty-string-conversion" = "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:empty-string-conversion] reason="..."tx0 explain tx0/java:empty-string-conversion shows the same in the terminal. Found a false positive? Report it.