ExQuality.Stages.Credo (ExQuality v0.13.0)

View Source

Runs Credo static analysis on the codebase.

Executes mix credo --strict --format json (strictness is configurable) with MIX_ENV=dev, and turns each issue into an ExQuality.Finding.

JSON rather than the default output because credo's text format does not name the check that produced an issue, and because counting issues out of it meant five regexes against a summary line that a reader could not check. The count is now length(issues), and check is the check module (Credo.Check.Readability.ModuleDoc) rather than its category.

In an umbrella, each finding is tagged with the app its file belongs to, and the rendered output is grouped by app.

Output that does not parse is never hidden: a run that printed no JSON document is reported with whatever credo did say, which is what a version too old to know --format json produces.

Multiple configs

A .credo.exs can declare more than one config, and a check that lives in a second config does not run under the default one. credo: [configs: ["default", "migrations"]] runs mix credo once per name, in order, and merges the results into one stage result. Without it, one run happens with no --config-name, which is credo's own default.

The runs are serial, not concurrent. mix credo runs with MIX_ENV=dev and can compile, and two concurrent mix runs against the same _build is the hazard the reader/writer split in the analysis phase exists to avoid. The stage as a whole still runs in parallel with every other analysis stage.

Findings are deduplicated on {file, line, column, check} before sorting, because two configs whose files globs overlap can report the same issue twice, and a doubled count is worse than a missed one: it is not obviously wrong.

Note: Credo does not support auto-fix. All issues must be manually resolved.

Summary

Functions

Runs the credo stage.

Functions

run(config)

@spec run(keyword()) :: ExQuality.Stage.result()

Runs the credo stage.

Config options

  • strict - Use --strict mode (default: true)
  • all - Use --all flag to check all files (default: false)
  • configs - Names of the .credo.exs configs to run, in order (default: nil, meaning one run with no --config-name)