A shift distance is outside the range of the shifted type
What it finds
x << 32 with an int x shifts by 0, not 32: Java uses only the lowest five bits of the distance for an int and the lowest six for a long. A constant distance outside 0 to 31, or 0 to 63 for a long, never does what it says.
The type of the shifted value must be known from its declaration or a literal. A distance of 64 or more is wrong for both types and is reported whatever the type.
From the rule's source, shift_range.rs.
class Bits { long mask(int i, long l, byte b, Object o) { int a = i << 32;tx0 reports: shifting an int by 32 shifts it by 0 long c = l >>> 64;tx0 reports: shifting an long by 64 shifts it by 0 int d = b >> 40;tx0 reports: shifting an int by 40 shifts it by 8 long e = 1 << 40;tx0 reports: shifting an int by 40 shifts it by 8 i <<= -1;tx0 reports: shifting an int by -1 shifts it by 31 long f = 1L << 40; long g = l << 63; int h = i >>> 31; long k = ((Long) o) << 70;tx0 reports: shifting an long by 70 shifts it by 6 return a + c + d + e + f + g + h + k; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:shift-range" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:shift-range] reason="..."tx0 explain tx0/java:shift-range shows the same in the terminal. Found a false positive? Report it.