Skip to main content

CLI Commands

The following table shows all available analysis commands:

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 rule issues.
analyze-widgetsawdcm analyze-widgets libReports the quality and usage of your Flutter widgets.
analyze-assetsaadcm analyze-assets libReports various issues with image assets.
analyze-structureasdcm analyze-structure libShows how files depend on each other and on external packages.
fixfdcm fix libFixes issues produced by dcm analyze, dcm check-unused-code, dcm check-unused-files or dcm check-dependencies commands.
formatfmtdcm format libFormats *.dart files.
calculate-metricscmdcm calculate-metrics libReports code metrics.
check-code-duplicationcddcm check-code-duplication libReports duplicate functions, methods, constructors and test cases.
check-unused-codeucdcm check-unused-code libReports unused code declarations.
check-unused-filesufdcm check-unused-files libReports unused *.dart files.
check-dependenciesddcm check-dependencies libReports missing, under-promoted, over-promoted, and unused dependencies.
check-parameterspdcm check-parameters libReports various issues with functions, methods and constructors parameters.
check-unused-l10nuldcm check-unused-l10n libReports unused members of classes that provide localization strings.
check-exports-completenessecdcm check-exports-completeness libReports not exported declarations that are part of a package's public API.

For additional help on any of the commands:

$ dcm <command> --help

Supported Output Formats​

Each commands 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+
info

The HTML output format is supported only by calculate-metrics, analyze-assets and analyze-widgets.

Global Options​

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


--version Print the DCM version.


--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.

Excluding Files​

To excluded specific files when running DCM commands, pass the --exclude CLI option (by default, all generated files are excluded).

dcm analyze lib --exclude="{**/*.g.dart,**/*.freezed.dart}"
info

If you have multiple packages, each passed glob is evaluated relative to the root of the package (not the root of the analysis).

By default, all other code exclusion methods listed here are also applied.

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.