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

36 lines
1.1 KiB
HTML

<html>
<body>
Reports usages of the <code>+</code> unary operator. The unary plus is usually a null operation, and
its presence might represent a coding error. For example, in a combination with the increment operator (like in <code>+++</code>)
or with the equal operator (like in <code>=+</code>).
<p><b>Example:</b></p>
<pre><code>
void unaryPlus(int i) {
int x = + +i;
}
</code></pre>
<p>The following quick fixes are suggested:</p>
<ul>
<li><p>Remove <code>+</code> operators before the <code>i</code> variable:</p>
<pre><code>
void unaryPlus(int i) {
int x = i;
}
</code></pre>
</li>
<li><p>Replace <code>+</code> operators with the prefix increment operator:</p>
<pre><code>
void unaryPlus(int i) {
int x = ++i;
}
</code></pre>
</li>
</ul>
<!-- tooltip end -->
<p>
Use the checkbox below to report unary pluses that are used together with a binary or another unary expression.
It means the inspection will not report situations when a unary plus expression is used in array
initializer expressions or as a method argument.
</p>
</body>
</html>