Skip to main content

Command Line Interface

To use the package as a command-line tool, run:

$ dcm <command> lib

It will produce a result in one of the supported formats:

  • Console
  • GitHub
  • Checkstyle
  • Code Climate
  • HTML
  • JSON

Available commands

The following table shows which commands you can use with the tool:

CommandAliasExample of useShort description
initidcm init libGeneral command to set up DCM.
runrdcm run --analyze libRun multiple passed DCM commands at once.
analyzeadcm analyze libReports lint rules violations.
analyze-widgetsawdcm analyze-widgets libCollects quality score and usages of Flutter widgets.
fixfdcm fix libFixes issues produced by dcm analyze command.
formatfmtdcm format libFormats *.dart files.
calculate-metricscmdcm calculate-metrics libCollect code metrics for Dart code.
check-exports-completenessecdcm check-exports-completeness libChecks that an exported API exports all used types.
check-unnecessary-nullableundcm check-unnecessary-nullable libChecks unnecessary nullable parameters.
check-unused-filesufdcm check-unused-files libChecks unused *.dart files.
check-unused-l10nuldcm check-unused-l10n libChecks unused localization in *.dart files.
check-unused-codeucdcm check-unused-code libChecks unused code in *.dart files.
check-dependenciesddcm check-dependencies libChecks missing, under-promoted, over-promoted, and unused dependencies.

For additional help on any of the commands:

$ dcm <command> --help

Multi-package repositories usage

If you run a command from the root of a multi-package repository (a.k.a. monorepo), it'll pick up analysis_options.yaml files correctly.

Additionally, if you use Melos, you can add custom command to the melos.yaml.

melos.yaml
metrics:
run: |
melos exec -c 1 --ignore="*example*" -- \
dcm analyze lib
description: |
Run DCM in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.