View Source Credo.Check.Readability.StrictModuleLayout (Credo v1.6.4)
This check has a base priority of low and works with any version of Elixir.
Explanation
Provide module parts in a required order.
# preferred
defmodule MyMod do
@moduledoc "moduledoc"
use Foo
import Bar
alias Baz
require Qux
endLike 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:
:order
List of atoms identifying the desired order of module parts.
Supported values are:
:moduledoc-@moduledocmodule attribute:shortdoc-@shortdocmodule attribute:behaviour-@behaviourmodule attribute:use-useexpression:import-importexpression:alias-aliasexpression:require-requireexpression:defstruct-defstructexpression:opaque-@opaquemodule attribute:type-@typemodule attribute:typep-@typepmodule attribute:callback-@callbackmodule attribute:macrocallback-@macrocallbackmodule attribute:optional_callbacks-@optional_callbacksmodule attribute:module_attribute- other module attribute:public_fun- public function:private_fun- private function or a public function marked with@doc false:public_macro- public macro:private_macro- private macro or a public macro marked with@doc false:callback_impl- public function or macro marked with@impl:public_guard- public guard:private_guard- private guard or a public guard marked with@doc false:module- inner module definition (defmoduleexpression inside a module)
Notice that the desired order always starts from the top.
For example, if you provide the order ~w/public_fun private_fun/a,
it means that everything else (e.g. @moduledoc) must appear after
function definitions.
This parameter defaults to [:shortdoc, :moduledoc, :behaviour, :use, :import, :alias, :require].
:ignore
List of atoms identifying the module parts which are not checked, and may
therefore appear anywhere in the module. Supported values are the same as
in the :order param.
This parameter defaults to [].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.