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
- Codeclimate
- HTML
- JSON
Available commands
The following table shows which commands you can use with the tool:
Command | Alias | Example of use | Short description |
---|---|---|---|
init | i | dcm init lib | General command to set up DCM. |
analyze | a | dcm analyze lib | Reports lint rules violations. |
analyze-widgets | aw | dcm analyze-widgets lib | Collects quality score and usages of Flutter widgets. |
fix | f | dcm fix lib | Fixes issues produced by dcm analyze command. |
format | fmt | dcm format lib | Formats *.dart files. |
calculate-metrics | cm | dcm calculate-metrics lib | Collect code metrics for Dart code. |
check-exports-completeness | ec | dcm check-exports-completeness lib | Checks that an exported API exports all used types. |
check-unnecessary-nullable | un | dcm check-unnecessary-nullable lib | Checks unnecessary nullable parameters. |
check-unused-files | uf | dcm check-unused-files lib | Checks unused *.dart files. |
check-unused-l10n | ul | dcm check-unused-l10n lib | Checks unused localization in *.dart files. |
check-unused-code | uc | dcm check-unused-code lib | Checks unused code in *.dart files. |
check-dependencies | d | dcm check-dependencies lib | Checks 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.