LexCredo.Check.Warning.NoPipeIntoCase (LexCredo v0.1.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

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

Explanation

Do not pipe into case expressions.

Assign intermediate results to a variable and pass it to case directly. Piping into case is hard to read and can obscure the subject of the match.

# BAD
build_post(attrs)
|> store_post()
|> case do
  {:ok, post} -> post
  {:error, _} -> nil
end

# GOOD
changeset = build_post(attrs)
case store_post(changeset) do
  {:ok, post} -> post
  {:error, _} -> nil
end

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 can be applied.

Parameters can be configured via the .credo.exs config file.