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