# `LexCredo.CheckHelpers`
[🔗](https://github.com/sippy-platform/lex_credo/blob/main/lib/lex_credo/check_helpers.ex#L1)

Shared utility functions for LexCredo checks.

# `skip_for_test_file?`

```elixir
@spec skip_for_test_file?(Credo.SourceFile.t(), keyword(), module()) :: boolean()
```

Returns `true` when the file should be skipped because it is a test file
and the `:exclude_test_files` param resolves to `true` for the given check module.

Used by all LexCredo checks to implement the `exclude_test_files` parameter
uniformly.

## Examples

    # Typical use inside a check's run/2:
    def run(%SourceFile{} = source_file, params) do
      if CheckHelpers.skip_for_test_file?(source_file, params, __MODULE__) do
        []
      else
        # ... run the check
      end
    end

# `test_file?`

```elixir
@spec test_file?(Credo.SourceFile.t()) :: boolean()
```

Returns `true` if the source file is a test file (path contains `/test/` or
filename ends with `_test.exs`).

## Examples

    iex> LexCredo.CheckHelpers.test_file?(%Credo.SourceFile{filename: "test/my_test.exs"})
    true

    iex> LexCredo.CheckHelpers.test_file?(%Credo.SourceFile{filename: "test/support/factory.ex"})
    true

    iex> LexCredo.CheckHelpers.test_file?(%Credo.SourceFile{filename: "lib/my_module.ex"})
    false

---

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