mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
37 lines
1.4 KiB
HTML
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> |