# no-duplicate-else-if

Disallow else-if conditions made unreachable by earlier conditions

An else-if condition that implies an earlier condition can never select its body.
Instead, you SHOULD remove the unreachable branch or correct the conditions so each branch can be selected.

- Category: suspicious
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
function classify(value: int32): string {
    if (value > 0) {
        return "positive";
    } else if (value > 0 && value < 10) {
        return "small";
    }
    return "other";
}
```

## Accepted

```ds title="main.ds"
function classify(value: int32): string {
    if (value > 0 && value < 10) {
        return "small";
    } else if (value > 0) {
        return "positive";
    }
    return "other";
}
```

## Prior art

- [ESLint · no-dupe-else-if](https://eslint.org/docs/latest/rules/no-dupe-else-if)

[language/linter/src/rules/suspicious/no_duplicate_else_if.rs:7](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/suspicious/no_duplicate_else_if.rs#L7)
