# `LexCredo.Check.Warning.PreferBooleanOperators`
[🔗](https://github.com/sippy-platform/lex_credo/blob/main/lib/lex_credo/check/warning/prefer_boolean_operators.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `normal` and works with any version of Elixir.

## Explanation

Use `and`/`or`/`not` instead of `&&`/`||`/`!` when operands are booleans.

The strict boolean operators make intent clear and catch accidental truthy
values (e.g. `:undefined` from Erlang APIs). This check flags `&&`, `||`,
and `!` when at least one operand is clearly boolean-returning — i.e. an
`is_*` guard call, a comparison operator, or another boolean operator.

    # BAD — operands are boolean-typed
    is_binary(x) && is_integer(y)
    has_permission?(user) || is_admin?(user)
    !is_nil(value)

    # GOOD
    is_binary(x) and is_integer(y)
    has_permission?(user) or is_admin?(user)
    not is_nil(value)

    # NOT flagged — truthy/falsy short-circuit idiom, not boolean-typed
    user && user.name
    config[:timeout] || 5_000

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:exclude_test_files`

  When `true`, skips test files. Default: `false`.

*This parameter defaults to* `false`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
