View Source mix credo suggest

suggest suggests issues to fix in your code.

Examples

$ mix credo
$ mix credo suggest                 # same thing, since it's the default command
$ mix credo --strict --format=json  # include low priority issues, output as JSON
$ mix credo suggest --help          # more options

$ mix credo suggest --format json
$ mix credo suggest lib/**/*.ex --only consistency --strict
$ mix credo suggest --checks-without-tag formatter --checks-without-tag controversial

Command Line Switches

Name, shorthandDescription
--all, -aShow all issues for each category
--all-priorities, -AShow all issues including low priority ones
--checksOnly include checks that match the given comma-seperated patterns
--checks-with-tagOnly include checks that match the given tag
--checks-without-tagIgnore checks that match the given tag
--config-fileUse the given config file as Credo's config
--config-nameUse the given config instead of "default"
--enable-disabled-checksRe-enable disabled checks that match the given comma-seperated patterns
--files-includedOnly include these files
--files-excludedExclude these files
--formatDisplay the list in a specific format (json, flycheck, sarif or oneline)
--ignore-checksIgnore checks that match the given comma-seperated patterns
--ignoreAlias for --ignore-checks
--min-priorityMinimum priority to show issues
--mute-exit-statusExit with status zero even if there are issues
--onlyAlias for --checks
--strictAlias for --all-priorities
--verboseAdditionally print the check and the source code that raised the issue

Descriptions

--all

Show all issues for each category

By default, Credo's report is limited to 5 issues per category.

$ mix credo --all

--all-priorities (aliased as --strict)

Show all issues including low priority ones

By default, Credo's report is limited to high priority issues as indicated by the arrows (↑ ↗ → ↘ ↓) next to each issue.

$ mix credo --strict

--checks (aliased as --only)

Only include checks that match the given comma-seperated patterns

# Run only checks where the name matches "readability" or "space" (case-insensitive),
# e.g. `Credo.Check.Readability.ModuleDoc` or `Credo.Check.Consistency.SpaceAroundOperators`
$ mix credo --only readability,space

The patterns are also compiled using Regex.compile/2, which allows for more complex queries:

# Run only checks where the name matches "readability" and "space"
# (case-insensitive), e.g. `Credo.Check.Readability.SpaceAfterCommas`
$ mix credo --only readability.+space

--checks-with-tag

Only include checks that match the given tag (can be used multiple times)

$ mix credo --checks-with-tag experimental --checks-with-tag controversial

--checks-without-tag

Ignore checks that match the given tag (can be used multiple times)

$ mix credo --checks-without-tag formatter

--config-file

Use the given config file as Credo's config

$ mix credo --config-file ./path/to/credo.exs

This disables Transitive configuration files and only the given config file is

--config-name

Use the given config instead of "default"

$ mix credo --config-name special-ci-config

--enable-disabled-checks

Re-enable disabled checks that match the given comma-seperated patterns

# Enable all disabled checks where the name matches "readability" or "space" (case-insensitive),
# e.g. `Credo.Check.Readability.ModuleDoc` or `Credo.Check.Consistency.SpaceAroundOperators`
$ mix credo --enable-disabled-checks readability,space

The patterns are also compiled using Regex.compile/2, which allows for more complex queries:

# Enable all previously disabled checks where the name matches "readability" and "space"
# (case-insensitive), e.g. `Credo.Check.Readability.SpaceAfterCommas`
$ mix credo --enable-disabled-checks readability.+space

# Enable *all* disabled checks by simply using:
$ mix credo --enable-disabled-checks .+

--files-included

Only include these files (accepts globs, can be used multiple times)

$ mix credo --files-included "./lib/**/*.ex" --files-included "./src/**/*.ex"

--files-excluded

Exclude these files (accepts globs, can be used multiple times)

$ mix credo --files-excluded "./test/**/*.exs"

--format

Display the list in a specific format (json, flycheck, sarif or oneline)

$ mix credo --format json

--ignore-checks (aliased as --ignore)

Ignore checks that match the given comma-seperated patterns

# Ignore checks where the name matches "readability" or "space" (case-insensitive),
# e.g. `Credo.Check.Readability.ModuleDoc` or `Credo.Check.Consistency.SpaceAroundOperators`
$ mix credo --ignore readability,space

The patterns are also compiled using Regex.compile/2, which allows for more complex queries:

# Ignore checks where the name matches "readability" and "space"
# (case-insensitive), e.g. `Credo.Check.Readability.SpaceAfterCommas`
$ mix credo --ignore readability.+space

--ignore

Alias for --ignore-checks

--min-priority

Minimum priority to show issues (higher,high,normal,low,ignore or number)

$ mix credo --min-priority high

--mute-exit-status

Exit with status zero even if there are issues

$ mix credo --format json
# ...

$ echo $?
0

--only

Alias for --checks

--strict

Alias for --all-priorities

--verbose

Additionally print the check and the source code that raised the issue

$ mix credo --verbose

# ...

┃ [W] ↗ There should be no calls to IO.inspect/1. [Credo.Check.Warning.IoInspect]
┃       lib/foo/bar.ex:121:6 #(Foo.Bar.run)
┃       |> IO.inspect(label: "Arguments given")
┃          ^^^^^^^^^^