Files
2025-02-05 04:43:28 +00:00

33 lines
848 B
HTML

<html>
<body>
Reports unnecessary unary minuses. Such expressions might be hard to understand and might contain errors.
<p><b>For example:</b></p>
<pre><code>void unaryMinus(int i) {
int x = - -i;
}</code></pre>
<p>The following quick fixes are suggested here:</p>
<ul>
<li><p>Remove <code>-</code> operators before the <code>i</code> variable:</p>
<pre><code>void unaryMinus(int i) {
int x = i;
}</code></pre>
</li>
<li>
<p>Replace <code>-</code> operators with the prefix decrement operator:</p>
<pre><code>void unaryMinus(int i) {
int x = --i;
}</code></pre>
</li>
</ul>
<p><b>Another example:</b></p>
<pre><code>void unaryMinus(int i) {
i += - 8;
}</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>void unaryMinus(int i) {
i -= 8;
}</code></pre>
<!-- tooltip end -->
</body>
</html>