sfox_credo
Credo checks used for Elixir projects at sFOX.
Installation
Add sfox_credo to your dependencies in mix.exs:
def deps do
[
{:sfox_credo, "~> 0.2"}
]
end
Documentation is found on HexDocs.
Usage
sfox_credo provides two plugins to add to the profile plugins list in
.credo.exs:
-
SfoxCredo.Standard: Add this topluginsto configure standard Credo checks (including some that will be in the next minor release) as used by sFOX. -
SfoxCredo.Custom: Add this topluginsto configure Credo checks written by sFOX. The checks are grouped by their Credo tag; see Selecting custom checks.
When using these plugins, it is strongly recommended that the enabled
configuration block be omitted from your .credo.exs. Checks to be disabled
should be added to the disabled list and additional or reconfigured checks
should be placed in the extra list. Otherwise, it will be necessary for you
to manually configure everything.
Selecting custom checks
Each check in SfoxCredo.Custom belongs to one group.
-
:correctness(enabled by default)SfoxCredo.Check.Warning.AvoidAtomToString: preferto_string/1overAtom.to_string/1.
-
:docs(enabled by default)SfoxCredo.Check.Readability.DocFencedCode: code examples and doctests in documentation are fenced Elixir blocks.SfoxCredo.Check.Readability.DocHeadingLevel: documentation headings start at##and don't skip levels. Also verifies admonition formatting.SfoxCredo.Check.Readability.DocListStyle: documentation lists use-and aren't indented from the surrounding text.
-
:ecto(disabled by default)Ectochecks can only be enabled whenectois a dependency.SfoxCredo.Check.Design.EctoMigrationTimestamps: Ecto migrations create tables with both timestamp columns.
-
:ash(disabled by default)Ashchecks can only be enabled whenashis a dependency.SfoxCredo.Check.Refactor.AshCallInEnum: Checks forAshcalls that go to the data layer once for each element of a collection.
-
:security(enabled by default)SfoxCredo.Check.Warning.LoggerMessageInspect: noinspect/1in Logger messages.SfoxCredo.Check.Warning.LoggerMetadataInspect: noinspect/1in Logger metadata values.
-
:suppressions(enabled by default)SfoxCredo.Check.Readability.DisableWithoutReason: Checks that each# credo:disable-*(and other tool suppressions) comment has a reason in the comment block directly above it.
Change the selection with the include and exclude plugin params. exclude
wins when a group is in both. Any other param, or an unknown group, stops Credo
with an error.
plugins: [{SfoxCredo.Custom, include: [:ecto], exclude: [:docs]}]
Checks outside the selection aren't registered. Enable or configure a single
check in your own extra list:
checks: %{
extra: [
{SfoxCredo.Check.Readability.DocListStyle, []},
{SfoxCredo.Check.Warning.LoggerMessageInspect, extra_loggers: [MyApp.Logger]}
]
}
If SfoxCredo.Custom is listed in more than one config file (a project's
.credo.exs and its umbrella's, say), the params of the config closest to the
project are used, as with every other Credo setting.
Both plugins register their checks under the config name in effect, so they
also apply with mix credo --config-name.
If you use enabled in your check configuration, Credo ignores the plugin's
checks; list the checks you want from the groups above in enabled yourself.
Semantic Versioning
sfox_credo follows Semantic Versioning 2.0.