# double-comparisons

Prefer one comparison over an equivalent pair of comparisons

Two comparisons that repeat identical operand computations can encode the same relation as one comparison.
Instead, you SHOULD use the equivalent single operator.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function atMost(left: int32, right: int32): boolean {
    return left < right || left === right;
}
```

## Accepted

```ds title="main.ds"
function atMost(left: int32, right: int32): boolean {
    return left <= right;
}
```

## Prior art

- [Clippy · double_comparisons](https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons)

[language/linter/src/rules/style/double_comparisons.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/double_comparisons.rs#L8)
