Credo.Check.Readability.PipeIntoAnonymousFunctions (Credo v1.6.1) View Source

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

Explanation

Avoid piping into anonymous functions.

The code in this example ...

def my_fun(foo) do
  foo
  |> (fn i -> i * 2 end).()
  |> my_other_fun()
end

... should be refactored to define a private function:

def my_fun(foo) do
  foo
  |> times_2()
  |> my_other_fun()
end

defp timex_2(i), do: i * 2

Like all Readability issues, this one is not a technical concern. But you can improve the odds of others reading and liking your code by making it easier to follow.

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

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