mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
24 lines
953 B
HTML
24 lines
953 B
HTML
<html>
|
|
<body>
|
|
Reports <code>if</code> statements that throw only <code>java.lang.Throwable</code> from a <code>then</code> branch
|
|
and do not have an <code>else</code> branch. Such statements can be converted to more compact <code>assert</code> statements.
|
|
<p>
|
|
The inspection also reports Guava's <code>Preconditions.checkNotNull()</code>.
|
|
They can be replaced with a <code>Objects.requireNonNull()</code> call for which a library may not be needed.</p>
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
<b>if</b> (x == 2) <b>throw new</b> RuntimeException("fail");
|
|
<b>if</b> (y == null) <b>throw new</b> AssertionError();
|
|
Preconditions.checkNotNull(z, "z");
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
<b>assert</b> x != 2 : "fail";
|
|
Objects.requireNonNull(y);
|
|
Objects.requireNonNull(z, "z");
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>By default, this inspection provides a quick-fix in the editor without code highlighting.</p>
|
|
</body>
|
|
</html>
|