OptimumCredo.Check.Readability.CastListOrder (OptimumCredo v0.5.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Keep field lists passed to cast/3 and validate_required/2 alphabetical.
Bad
cast(user, attrs, [:name, :email, :age])Good
cast(user, attrs, [:age, :email, :name])Only literal lists with at least min_run atoms (or strings) are checked.
Unqualified calls count when the file has import Ecto.Changeset (configurable).
Check-Specific Parameters
Use the following parameters to configure this check:
:min_run
Minimum list length that is checked.
This parameter defaults to 3.
:functions
Changeset function names to inspect.
This parameter defaults to [:cast, :validate_required].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.