String.toString
is redundant and inefficient, use the string directly instead72
73 for (String j : paramStrings) {
74 String[] vals = j.split(":");
75 params.put(vals[0].toString(), new String(vals[1]));76 }
77
78 var configElem = new ConfigData();
Description
Calling String.toString
is a redundant operation. Just use the string directly.
Bad Practice
String b = "abc".toString();
Recommended
String b = "abc";
Exceptions
There are some exceptions to this, such as within generated code where such statements are likely to appear. Consider adding these files to the exclude_files
or exclude_patterns
to reduce false positives.
References
- Spotbugs - DM_STRING_TOSTRING