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

24 lines
925 B
HTML

<html>
<body>
Reports pointless bitwise expressions.
<p>
Such expressions include applying the <code>&</code> operator to the maximum value for the given type, applying the
<code>or</code> operator to zero, and shifting by zero. Such expressions may be the result of automated
refactorings not followed through to completion and are unlikely to be originally intended.</p>
<p><b>Examples:</b></p>
<pre><code>
// Warning: operation is pointless and can be replaced with just `flags`
// 0xFFFF_FFFF is the maximum value for an integer, and both literals are treated
// as 32 bit integer literals.
int bits = flags & 0xFFFF_FFFF;
// Warning: operation is pointless and can be replaced with just `bits`
// OR-ing with 0 always outputs the other operand.
int or = bits | 0x0;
// Warning: operation is pointless, as always results in 0
int xor = or ^ or;
</code></pre>
<!-- tooltip end -->
</body>
</html>