CLI Commands
The following table shows all available analysis commands:
Command | Alias | Example of use | Short description |
---|---|---|---|
init | i | dcm init lib | General command to set up DCM. |
run | r | dcm run --analyze lib | Runs multiple passed DCM commands at once. |
analyze | a | dcm analyze lib | Reports lint rule issues. |
analyze-widgets | aw | dcm analyze-widgets lib | Reports the quality and usage of your Flutter widgets. |
analyze-assets | aa | dcm analyze-assets lib | Reports various issues with image assets. |
analyze-structure | as | dcm analyze-structure lib | Shows how files depend on each other and on external packages. |
fix | f | dcm fix lib | Fixes issues produced by dcm analyze , dcm check-unused-code , dcm check-unused-files or dcm check-dependencies commands. |
format | fmt | dcm format lib | Formats *.dart files. |
calculate-metrics | cm | dcm calculate-metrics lib | Reports code metrics. |
check-code-duplication | cd | dcm check-code-duplication lib | Reports duplicate functions, methods, constructors and test cases. |
check-unused-code | uc | dcm check-unused-code lib | Reports unused code declarations. |
check-unused-files | uf | dcm check-unused-files lib | Reports unused *.dart files. |
check-dependencies | d | dcm check-dependencies lib | Reports missing, under-promoted, over-promoted, and unused dependencies. |
check-parameters | p | dcm check-parameters lib | Reports various issues with functions, methods and constructors parameters. |
check-unused-l10n | ul | dcm check-unused-l10n lib | Reports unused members of classes that provide localization strings. |
check-exports-completeness | ec | dcm check-exports-completeness lib | Reports 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+
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
.
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}"
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
.
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.