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 Free+
  • HTML Pro+
  • GitHub Teams+
  • Checkstyle Teams+
  • Code Climate Teams+
  • JSON Teams+
  • Sonar Teams+

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 libRuns multiple passed DCM commands at once.
analyzeadcm analyze libReports lint rules violations.
analyze-widgetsawdcm analyze-widgets libCollects quality score and usages of Flutter widgets.
analyze-assetsaadcm analyze-assets libChecks various issues with image assets.
analyze-structureasdcm analyze-structure libShows how files depend on each other and external packages.
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 a package exports all types that are part of public API.
check-parameterspdcm check-parameters libChecks various issues with 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

Global Options​

Global options:
-h, --help Print this usage information.


--version Reports the version of this tool.


--show-installation-hint Show a hint on how to install this particular DCM version.

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.

Manually Locating the Dart SDK​

If for some reason the Dart SDK was not located automatically (and you have it in your PATH), pass the --sdk-path CLI option with the absolute path to the SDK folder when calling any DCM command.

For a locally installed Flutter SDK, the expected folder is named dart-sdk and is typically located at ...flutter/bin/cache/dart-sdk (where flutter is the Flutter SDK folder).

Alternatively, you can run which dart (or an alternative Windows command) and replace /dart with /cache/dart-sdk.

note

If you are setting the path to the Dart SDK manually, consider reaching out to our support team.

We are interested in supporting as many cases as possible to ultimately reduce the need for manual setup to zero.