Skip to main content
Teams

Run

Run multiple passed DCM commands at once with the merged output (console, code climate / gitlab, json).

info

This command is supposed to be used on CI/CD. It has no progress indication and does not show any output on a successful run.

To execute the command, run:

$ dcm run --analyze --unused-code lib # or dcm r --analyze --unused-code lib

Full command description:

Usage: dcm run [arguments] <directories>
-h, --help Print this usage information.


--analyze Run dcm analyze.
--metrics Run dcm calculate-metrics.
--analyze-widgets Run dcm analyze-widgets.
--code-duplication Run dcm check-code-duplication.
--unused-code Run dcm check-unused-code.
--unused-files Run dcm check-unused-files.
--unused-l10n Run dcm check-unused-l10n.
--dependencies Run dcm check-dependencies.
--unnecessary-nullable Run dcm check-unnecessary-nullable.
--parameters Run dcm check-parameters.
--exports-completeness Run dcm check-exports-completeness.


Analyze widgets options:
--show-similarity Include similar widgets into the report.
--threshold Set a minimum threshold after which widgets are considered similar.
(defaults to "0.2")


Code duplication options:
--per-package Compare code for duplications only within one package.
--exclude-overrides Exclude methods marked with @override.
--statements-threshold Minimum number of statements inside a declaration block.
(defaults to "3")


Unused code options:
--no-exclude-overridden Do not treat overridden members as always used.


Unused localization options:
-p, --class-pattern=<I18n$> The pattern to detect classes providing localization.
(defaults to "I18n$")


Dependencies options:
--ignored-packages=<my-package,other,...> Package names that should be ignored.


Parameters options:
--show-same-value Include parameters that always get the same constant argument.
--show-unused-default-value Include parameters with default values that always get an argument.
--show-redundant Include parameters whose values are always passed with another parameter.
--show-unused-vft Include @visibleForTesting parameters that are never used in tests.
--show-broad-types Include parameters whose types can be made more specific.


-r, --reporter=<console> Analysis output format.
[console (default), json, codeclimate, gitlab, checkstyle]
-a, --absolute-path Show absolute paths in console reporter output.
--json-path=<path/to/file.json> Path to the JSON file with the analysis output.


-c, --print-config Print resolved config.


--root-folder=<./> Root folder.
(defaults to the current directory)
--sdk-path=<directory-path> Dart SDK directory path.
If the project has a `.fvm/flutter_sdk` symlink, it will be used if the SDK is not found.
--exclude=<{**/*.g.dart,**/*.freezed.dart}> Files to exclude (in Glob syntax).
(defaults to "{**/*.g.dart,**/*.freezed.dart}")


--ci-key The license key to run on CI server. Can be provided via DCM_CI_KEY env variable.
--email The email used to purchase the license. Can be provided via DCM_EMAIL env variable.


--no-analytics Disable sending anonymous usage statistics.


--monorepo Include publicly exported code into the check.


--[no-]fatal-found Treat any found issue as fatal.
(defaults to on)

Output example

Console

Use --reporter=console to enable this format.

Console

JSON

The reporter prints a single JSON object containing meta information and the violations grouped by a file. Use --reporter=json to enable this format.

The root object fields are

  • formatVersion - an integer representing the format version (will be incremented each time the serialization format changes)
  • timestamp - a creation time of the report in YYYY-MM-DD HH:MM:SS format
  • analyzeResults - an array of "analyze" command results
  • metricResults - an array of "calculate-metrics" command results
  • widgetResults - an array of "analyze-widgets" command results
  • unusedCodeResults - an array of "check-unused-code" command results
  • unusedFilesResults - an array of "check-unused-files" command results
  • unusedL10nResults - an array of "check-unused-l10n" command results
  • dependenciesResults - an array of "check-dependencies" command results
  • unnecessaryNullableResults - an array of "check-unnecessary-nullable" command results
  • parametersResults - an array of "check-parameters" command results
  • exportResults - an array of "check-exports-completeness" command results
note

You can find more details about the format on each command's documentation page.

GitLab and Code Climate

GitLab and Code Climate formats are also supported. Refer to the analyze commands docs to set up them.

Checkstyle

Use --reporter=checkstyle to enable this format.

<?xml version="1.0"?>
<checkstyle version="10.0">
<file name="../abstract_class.dart">
<error line="0" severity="info" message="simple design message" source="designId"/>
<error line="5" column="3" severity="warning" message="This function has 2 duplicate declarations" source="duplication-issue"/>
<error line="5" column="3" severity="warning" message="Unused class SomeClass" source="unused-code-issue"/>
<error line="0" severity="warning" message="another_package, package should be listed in dev dependencies" source="dependency-issue"/>
</file>
<file name="../class_with_factory_constructors.dart">
<error line="0" severity="warning" message="simple message" source="id"/>
<error line="0" severity="warning" message="some_package is not used" source="dependency-issue"/>
</file>
<file name="relative_root.dart">
<error line="5" column="3" severity="warning" message="This method is a duplicate of doWork (located at ../abstract_class.dart). Target declaration has 1 other duplicate." source="duplication-issue"/>
<error line="5" column="3" severity="warning" message="This function is a duplicate of doWork (located at ../abstract_class.dart). Target declaration has 1 other duplicate." source="duplication-issue"/>
</file>
</checkstyle>