View Source Credo.Check.Refactor.AppendSingleItem (Credo v1.7.5)
This check is disabled by default.
Learn how to enable it via
This check is tagged
This means that this check is more opinionated than others and not for everyone's taste.
This check has a base priority of
low and works with any version of Elixir.
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.
list = list_so_far ++ [new_item]
# refactoring it like this can make the code faster:
list = [new_item] ++ list_so_far
There are no specific parameters for this check.
Like with all checks, general params can be applied.
Parameters can be configured via the
.credo.exs config file.