Do int arithmetic in long when its result widens to long

Proprietary

Changes an int expression that is converted to long by widening, in an assignment, invocation, casting or numeric context, and that contains a *, +, - or << of type int, so that this arithmetic is done in long and cannot overflow before the conversion. An int literal operand gets an L, as in seconds * 1000L, and otherwise an operand is cast, as in (long) a * b. Results change only where the int arithmetic overflowed or shifted by 32 or more. Arithmetic under a >> or >>>, whose result in long can differ where the int arithmetic did not overflow, is marked instead. A constant expression is changed only when its value differs from the same arithmetic done in long. Code whose types cannot be resolved is not changed.

io.moderne.staticanalysis.WidenIntArithmeticToLong
mod run . --recipe=io.moderne.staticanalysis.WidenIntArithmeticToLong

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.