Skip to content

Files

Latest commit

 

History

History
21 lines (13 loc) · 504 Bytes

UnnecessaryModOne.md

File metadata and controls

21 lines (13 loc) · 504 Bytes

Pattern: Unnecessary exp % 1

Issue: -

Description

Any expression mod 1 (exp % 1) is guaranteed to always return zero. This code is probably an error, and should be either exp & 1 or exp % 2.

Examples:

if (exp % 1) {}         // violation
if (method() % 1) {}    // violation

if (exp & 1) {}     // ok
if (exp % 2) {}     // ok

Further Reading