# prefer-is-empty

Prefer isEmpty over comparisons with zero length

Zero comparisons over canonical length and size members duplicate the `isEmpty` query.
Instead, you SHOULD use `isEmpty`, negating it when the comparison asks whether elements exist.

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

## Reported

```ds title="main.ds"
function empty(values: int32[]): boolean {
    return values.length === 0;
}
```

## Accepted

```ds title="main.ds"
function empty(values: int32[]): boolean {
    return values.isEmpty;
}
```

## Prior art

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

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