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

31 lines
1.0 KiB
HTML

<html>
<body>
Reports usages of the ternary condition operator and suggests converting them to <code>if</code>/<code>else</code> statements.
<p>Some code standards prohibit the use of the condition operator.</p>
<p>Example:</p>
<pre><code>
Object result = (condition) ? foo() : bar();
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
Object result;
if (condition) {
comp = foo();
}
else {
comp = bar();
}
</code></pre>
<!-- tooltip end -->
<p>Configure the inspection:</p>
<p>Use the <b>Ignore for simple assignments and returns </b> option to ignore simple assignments and returns and allow the following constructs:</p>
<pre><code>
String s = (foo == null) ? "" : foo.toString();
</code></pre>
<p>
Use the <b>Ignore places where an if statement is not possible </b> option to ignore conditional expressions in contexts in which automatic
replacement with an if statement is not possible (for example, when the conditional expression is used as an argument to a
<code>super()</code> constructor call).
</p>
</body>
</html>