View Source mix credo diff

diff suggests issues to fix in your code (based on git-diff).


Example usage:

$ mix credo diff v1.4.0
$ mix credo diff main
$ mix credo diff --from-git-ref HEAD --files-included "lib/**/*.ex"

$ mix credo diff --help               # more options

Command Line Switches

There are a couple of switches to control the diff parameters:

Name, shorthandDescription
--from-dirDiff from the given directory
--from-git-refDiff from the given Git ref
--from-git-merge-baseDiff from where the current HEAD branched off from the given merge base
--sinceDiff from the given point in time (using Git)

Using common switches

To adjust the analysis all command line switches of the suggest command are supported.

This means you can define to run the analysis in strict mode just like you would without diffing:

$ mix credo diff --from-git-ref v1.3.1 --strict

Using a different config

This also means that you don't have to run the "before version" with its config and the "after version" with its config.

In some cases you might want to enable a check and then only see the issues for that check that are added between "before" and "after".

You can just "pin" the config to the current one:

$ mix credo diff --from-git-ref v1.3.1 --config-file .credo.exs



Diff from the given directory. This is a great option if you are not using git for version control.

$ mix credo diff --from-dir ../my-project-v1.3.1


Diff from the given Git ref by comparing Credo's analysis for the given ref with HEAD.

$ mix credo diff --from-git-ref v1.3.1

To oversimplify, this runs Credo on the code points returned by git diff.


Diff from where the current HEAD branched off from the given merge base.

$ mix credo diff --from-git-merge-base develop

This runs Credo only on the things that changed on your branch after it branched off of the given ref.