Pattern: Redundant comparison
Issue: -
Double comparisons using logical operators can often be simplified to a single comparison. These redundant comparisons make code harder to read and maintain.
Example of incorrect code:
if (x === y || x < y) {
// Can be simplified
}
if (x < y || x === y) {
// Same redundant pattern
}
Example of correct code:
if (x <= y) {
// Simplified
}
if (y >= x) {
// Alternative form
}