Credence.Pattern.NoRedundantToList
(credence v0.7.1)
Copy Markdown
Detects Enum.to_list/1 used before a function that already accepts
any enumerable, making the conversion a redundant intermediate step.
MapSet.new/1 and Map.new/1 accept enumerables directly, so piping
through Enum.to_list/1 first adds an unnecessary list allocation.
Bad
Enum.to_list(items) |> MapSet.new()
items |> Enum.to_list() |> MapSet.new()
MapSet.new(Enum.to_list(items))Good
MapSet.new(items)
MapSet.new(items)
MapSet.new(items)