Redundant comparisons against constants results in always-true or always-false conditions. They add unnecessary complexity to the code and often
indicate a logical error where the developer might have intended a different comparison operator or a comparison with another value.
Code examples
Noncompliant code example
let status_code = 200;
if status_code <= 400 && status_code < 500 {} // Noncompliant: Redundant double comparison.
Compliant solution
let status_code = 200;
if status_code < 500 {} // Compliant: Corrected the comparison logic.