menu

manual-rotate

Prefer integer rotation operations over equivalent shift expressions

Combining complementary shifts of one unsigned integer with bitwise OR performs a bit rotation. Instead, you SHOULD call .rotateLeft() or .rotateRight() with the corresponding amount.

Reported

1function rotate(value: uint32): uint32 {2    return (value >> 8) | (value << 24);3}

Accepted

1function rotate(value: uint32): uint32 {2    return value.rotateRight(8);3}