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

40 lines
930 B
HTML

<html>
<body>
Reports method calls whose target is another method call.
The quick-fix suggests to introduce a local variable.
<p><b>Example:</b></p>
<pre><code>
class X {
int foo(File f) {
return f.getName().length();
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
class X {
int foo(File f) {
final String name = f.getName();
return name.length();
}
}
</code></pre>
<!-- tooltip end -->
<p>Use the inspection options to toggle warnings for the following cases:</p>
<ul>
<li>
<p>
chained method calls in field initializers,
for instance, <code>private final int i = new Random().nextInt();</code>
</p>
</li>
<li>
<p>
chained method calls operating on the same type,
for instance, <code>new StringBuilder().append("x: ").append(new X()).append("y: ").append(new Y()).toString();</code>.
</p>
</li>
</ul>
</body>
</html>