View Source Credo.Check.Warning.ExpensiveEmptyEnumCheck (Credo v1.7.8)
Basics
This check is enabled by default.
Learn how to disable it via
.credo.exs
.
This check has a base priority of high
and works with any version of Elixir.
Explanation
Checking if the size of the enum is 0
can be very expensive, since you are
determining the exact count of elements.
Checking if an enum is empty should be done by using
Enum.empty?(enum)
or
list == []
For Enum.count/2: Checking if an enum doesn't contain specific elements should be done by using
not Enum.any?(enum, condition)
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.