View Source Styler.Style.ModuleDirectives (Styler v0.6.0)
Styles up module directives!
This Style will expand multi-aliases/requires/imports/use and sort the directive within its groups (except uses, which cannot be sorted)
It also adds a blank line after each directive group.
credo-rules
Credo rules
Rewrites for the following Credo rules:
Credo.Check.Consistency.MultiAliasImportRequireUse(force expansion)Credo.Check.Readability.AliasOrder(we sort__MODULE__, which credo doesn't)Credo.Check.Readability.ModuleDoc(adds@moduledoc falseif missing. includes*.exsfiles)Credo.Check.Readability.MultiAliasCredo.Check.Readability.StrictModuleLayout(see section below for details)Credo.Check.Readability.UnnecessaryAliasExpansion
strict-layout
Strict Layout
This can break your code.
Modules directives are sorted into the following order:
@shortdoc@moduledoc@behaviouruseimportaliasrequire- everything else (unchanged)
If any of the sorted directives had a dependency on code that is now below it, your code will fail to compile after being styled.
For instance, the following will be broken because the module attribute definition will
be moved below the use clause, meaning @pi is undefined when invoked.
# before
defmodule Approximation do
@pi 3.14
use Math, pi: @pi
end
# after
defmodule Approximation do
@moduledoc false
use Math, pi: @pi
@pi 3.14
endFor now, it's up to you to come up with a fix for this issue. Sorry!
Link to this section Summary
Functions
Callback implementation for Styler.Style.run/2.
Link to this section Functions
Callback implementation for Styler.Style.run/2.