OptimumCredo.Check.Readability.DepsOrder (OptimumCredo v0.1.0)

View Source

Basics

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

Alphabetically ordered dependencies are more easily scannable by the reader.

# preferred

defp app_deps do
  [
    {:bcrypt_elixir, "~> 3.0"},
    {:mdex, "~> 0.4.0"},
    {:multipart, "~> 0.4"},
    {:number, "~> 1.0"},
    {:plug, "~> 1.14"}
  ]
end

# NOT preferred

defp app_deps do
  [
    {:bcrypt_elixir, "~> 3.0"},
    {:multipart, "~> 0.4"},
    {:number, "~> 1.0"},
    {:plug, "~> 1.14"},
    {:mdex, "~> 0.4.0"}
  ]
end

Dependencies should be alphabetically ordered within each deps group:

  • app_deps
  • optimum_deps

Like all Readability issues, this one is not a technical concern. But you can improve the odds of others reading and liking your code by making it easier to follow.

Check-Specific Parameters

Use the following parameters to configure this check:

:sort_method

The ordering method to use.

Options

  • :alpha - Alphabetical case-insensitive sorting.

This parameter defaults to :alpha.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.