Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of normal and works with any version of Elixir.
Explanation
Avoid writing named functions whose body is only a call to Enum.* or
Stream.*.
Such wrappers hide the collection structure, coupling the function to one
call-site shape and preventing reuse in Stream, Task.async_stream, or
comprehensions. Instead, write a function that operates on a single item
and compose it with Enum/Stream at the call site.
# BAD — parse_items/1 is only usable with a list
def parse_items(list), do: Enum.map(list, &String.to_integer/1)
# GOOD — parse_item/1 is reusable anywhere; caller composes with Enum
defp parse_item(item), do: String.to_integer(item)
collection |> Enum.map(&parse_item/1)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.