OptimumCredo.Check.Readability.SchemaFieldOrder (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 schema fields in alphabetical order so entries are predictable.
Bad
schema "posts" do
field :title, :string
field :body, :string
field :author, :string
endGood
schema "posts" do
field :author, :string
field :body, :string
field :title, :string
endA run must be at least min_run long. With group_associations: true, fields
and associations are checked as separate groups.
Check-Specific Parameters
Use the following parameters to configure this check:
:min_run
Minimum consecutive declarations needed before order is checked.
This parameter defaults to 3.
:group_associations
Order fields and associations as separate groups.
This parameter defaults to false.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.