View Source Credo.Check.Readability.PipeIntoAnonymousFunctions (Credo v1.7.0)
This check has a base priority of low
and works with any version of Elixir.
explanation
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
Check-Specific Parameters
There are no specific parameters for this check.
general-parameters
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs
config file.