ExQuality.Stages.Format (ExQuality v0.13.0)

View Source

Auto-fixes code formatting by running mix format.

Reports how many files were modified.

This is the only stage that modifies code - all other stages are read-only.

Projects with no formatter

mix format needs a .formatter.exs (or explicit patterns) and fails without one. That is a project that has never used the formatter, not a project with a problem, so the stage reports it as skipped rather than failing the run over a missing config file.

When formatting fails

mix format succeeds on any code it can parse, so the usual outcome is a pass. It does fail on a file with a syntax error, and the stage reports that rather than reading the file list out of the failed run: a SyntaxError line names no .ex file to count, so the stage used to print a green tick as the first line of a run on a broken file. Compile says the same thing moments later, but the run should not have claimed otherwise in the meantime.

Summary

Functions

Runs the format stage.

Functions

run(config)

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

Runs the format stage.

First checks which files need formatting, then formats them. Returns a result with the list of formatted files, the tool's output when mix format itself failed, or a :skipped result when the project has no .formatter.exs.