# `LexCredo.Check.Warning.UseStartSupervised`
[🔗](https://github.com/sippy-platform/lex_credo/blob/main/lib/lex_credo/check/warning/use_start_supervised.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

In test files, use `start_supervised!/1` to start processes instead of
calling `GenServer.start_link/2`, `Agent.start_link/2`, etc. directly.

`start_supervised!/1` registers the process with the test supervisor so it
is automatically cleaned up between tests, even if the test crashes. Direct
`start_link` calls bypass this and can leave processes running across tests,
causing hard-to-reproduce failures.

    # BAD
    {:ok, pid} = GenServer.start_link(MyServer, [])
    {:ok, agent} = Agent.start_link(fn -> %{} end)

    # GOOD
    pid = start_supervised!(MyServer)
    agent = start_supervised!({Agent, fn -> %{} end})

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:exclude_test_files`

  When `true`, skips test files (effectively disabling this check). 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*
