# no-needless-boolean-branch

Disallow conditionals that only produce opposite boolean literals

An `if` or ternary whose branches produce opposite boolean literals has the same result as its condition or its negation.
Instead, you SHOULD use the condition directly or negate it when the branches reverse the result.

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

## Reported

```ds title="main.ds"
function active(condition: boolean): boolean {
    if (condition) {
        return true;
    } else {
        return false;
    }
}
```

## Accepted

```ds title="main.ds"
function active(condition: boolean): boolean {
    return condition;
}
```

## Prior art

- [Clippy · needless_bool](https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool)
- [ESLint · no-unneeded-ternary](https://eslint.org/docs/latest/rules/no-unneeded-ternary)

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