Files
openide/java/java-impl/resources/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

37 lines
1.4 KiB
HTML

<html>
<body>
Reports unnecessary calls to static methods that convert their parameters to a string, e.g. <code>String.valueOf()</code> or <code>Integer.toString()</code>.
Such calls are unnecessary when used in string concatenations.
<p>Example:</p>
<pre><code>
System.out.println("Number: " + Integer.toString(count));
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
System.out.println("Number: " + count);
</code></pre>
Additionally such calls are unnecessary when used as arguments to library methods that do their own string conversion.
Some examples of library methods that do their own string conversion are:
<ul>
<li>
Classes <code>java.io.PrintWriter</code>, <code>java.io.PrintStream</code>
<ul><li><code>print()</code>, <code>println()</code></li></ul>
</li>
<li>
Classes <code>java.lang.StringBuilder</code>, <code>java.lang.StringBuffer</code>
<ul><li><code>append()</code></li></ul>
</li>
<li>
Class <code>org.slf4j.Logger</code>
<ul>
<li><code>trace()</code>, <code>debug()</code>, <code>info()</code>, <code>warn()</code>, <code>error()</code></li>
</ul>
</li>
</ul>
<!-- tooltip end -->
<p>
Use the <b>Report calls that can be replaced with a concatenation with the empty string</b>
option to also report cases where concatenations with the empty string can be used instead of a call to <code>String.valueOf()</code>.
</body>
</html>