A String is converted to a String with toString()
What it finds
name.toString() on a String returns the string itself, so the call only adds noise. The fix removes it; it is unsafe because the call throws for null, and code could rely on that.
From the rule's source, string_to_string.rs.
class Names { String show(String name, Object other) { String a = name.toString();tx0 reports: toString() is called on a String String b = other.toString(); return a + b; }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:string-to-string" = "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:string-to-string] reason="..."tx0 explain tx0/java:string-to-string shows the same in the terminal. Found a false positive? Report it.