View Source Credo.Check.Refactor.AppendSingleItem (Credo v1.6.7)
This check has a base priority of low
and works with any version of Elixir.
Explanation
When building up large lists, it is faster to prepend than append. Therefore: It is sometimes best to prepend to the list during iteration and call Enum.reverse/1 at the end, as it is quite fast.
Example:
list = list_so_far ++ [new_item]
# refactoring it like this can make the code faster:
list = [new_item] ++ list_so_far
# ...
Enum.reverse(list)
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.