# manual-strict-comparison

Prefer strict comparison over offsetting an operand by one

An inclusive integer comparison with an operand offset by one expresses strict ordering through extra arithmetic.
Instead, you SHOULD compare the original operands with `<` or `>`.

The rewritten comparison does not preserve an overflow trap produced by the offset at an integer boundary.

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

## Reported

```ds title="main.ds"
function isAfter(left: int32, right: int32): boolean {
    return left >= right + 1;
}
```

## Accepted

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

## Prior art

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

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