Erasing operations (e.g., any operation involving multiplying by zero, dividing zero by a value, or bitwise AND with zero) always result in zero
regardless of the operands, which makes the expression unnecessary and can be replaced directly with zero. This simplifies the code and avoids
potential confusion about the intent of the expression.
Code examples
Noncompliant code example
let x = 1;
let result = 0 * x; // Noncompliant: Result is always zero.
Compliant solution
let x = 1;
let result = 0; // Compliant: Simplified expression.