Runs a suite of static checks for the library.
The task works in three steps:
- Compile the project (and the test environment) as pre-checks. If compilation fails, nothing else runs.
- Run the checks (formatting, tests, docs, dependency audit, static analysis, ...).
- Print a summary of every check with its status and run time.
Re-running failures
To keep feedback fast, the task remembers the result of the previous run and re-runs only the checks that failed. Stale passing checks are skipped while failures remain.
This is only an optimization: as soon as the previously failing checks pass again, the task runs the remaining checks before reporting. An all-green result therefore always means every check ran and passed in this run.
There is no all-green result that covered only a subset of the checks.
Pass --all to ignore the remembered result and run every check from scratch.
mix libdev.check --all
Configuration
Configuration is read from a .libdev.exs file located at the root of your
project (the directory where you run mix libdev.check). The file is
optional: when it is missing the default checks are used as-is. It must
evaluate to a keyword list, and checks are configured under the top-level
:checks key.
The default checks are run as if your .libdev.exs contained the following:
# .libdev.exs
[
checks: [
credo: [argv: ["--all", "--strict"]],
format: [argv: ["--check-formatted"]],
test: [argv: ["--warnings-as-errors"]],
docs: [],
docs_check: [mix_task: "libdev.check.docs"],
mix_audit: [mix_task: "deps.audit"],
sobelow: [argv: ["--skip"]],
dialyzer: []
]
]You can override some checks by adding configuration that is deeply merged
into the default configuration. Disable a check completely with false.
# .libdev.exs
[
checks: [
credo: [argv: ["--all", "--no-strict"]],
docs: [env: %{"MIX_ENV" => "docs"}],
dialyzer: false
]
]Check options
Each check value is either a boolean or a keyword list:
false- disable the check entirely.true- keep the default configuration for the check (useful to undo afalsecoming from another configuration layer).a keyword list to override the default's options. Supported options are:
:mix_task- a string naming the Mix task to run for this check, when it differs from the check name (e.g."deps.audit"for the:mix_auditcheck).:argv- a list of strings appended to the underlying command's arguments (e.g.["--check-formatted"]).:env- environment variables to set for the check, as a map or keyword list ofstring => string(e.g.%{"MIX_ENV" => "test"}).
Overrides are deeply merged, so specifying one option leaves the other default
options of that check untouched. The values themselves are replaced, not
combined: a given :argv or :env overrides the default outright rather than
appending to it. For instance, the default :sobelow check passes
["--skip"];
override :argv with an empty list to drop that argument:
# .libdev.exs
[checks: [sobelow: [argv: []]]]Custom checks
The :checks list is not limited to the built-in checks above. Any extra
entry is run as its own check: its key is used as the name of the Mix task to
run, so my_task: [] runs mix my_task. Use :mix_task when the task name
differs from the key, plus :argv/:env as needed. The only requirement is
that the Mix task exists in your project.
# .libdev.exs
[checks: [coverage: [mix_task: "coveralls", argv: ["--raise"]], gettext: []]]