Skip to main content
Teams+

Run

Runs multiple DCM commands at once and provides the merged output (console, code climate / gitlab, json, checkstyle or sonar).

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.


--all Run all dcm commands.
--analyze Run dcm analyze.
--metrics Run dcm calculate-metrics.
--analyze-widgets Run dcm analyze-widgets.
--analyze-assets Run dcm analyze-assets.
--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.
--parameters Run dcm check-parameters.
--exports-completeness Run dcm check-exports-completeness.


Analyze widgets options:
--show-similarity Include similar widgets into the report.
--similarity-threshold (--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.
--lines-threshold Minimum number of lines for a duplication entry.
(defaults to "3")


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


Unused localization options:
-p, --class-pattern="^AppLocalizations$" Regular expression for class names to detect classes that provide localization (e.g., ^AppLocalizations$).
(defaults to "^AppLocalizations$")


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.


Assets options:
--size Size limit for image assets.
(defaults to "500KB")
--webp Require converting .jpg and .png images to .webp.
--naming Required naming convention for image assets.
[pascal, kebab, snake]
--[no-]resolution Find missing or incorrect resolution-aware image assets.
(defaults to on)
--allowed-formats List of allowed formats for particular folders (e.g. icons:svg).


Upload:
--upload Upload the output to DCM Dashboards.
--preview-upload Preview the uploaded result.
--project The project key.
--upload-date="year-month-day" Override upload date to any previous date (for example, 2025-01-30).
--with-details Include detailed reports into the uploaded result.


-r, --reporter="console" (--output-format) Analysis output format.
[console (default), json, codeclimate, gitlab, checkstyle, sonar]
-a, --absolute-path Show absolute paths in console reporter output.
--output-to="path/to/file" Path to the file with the analysis output.
--report-all Report all metrics, widgets and assets (default is to report only violations).


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


--root-folder="./" Root folder.
(defaults to the current directory)
-s, --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.
-e, --exclude="{**/*.g.dart,**/*.freezed.dart}" Files to exclude (in Glob syntax).
(defaults to "{**/*.g.dart,**/*.freezed.dart}")
--root-exclude Files to exclude, relative to the root folder (in Glob syntax).


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


--exclude-public-api (--ep) Exclude publicly exported code from the analysis output.


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

Suppressing Individual Commands​

Using --exclude affects all passed commands and won't help with configuring excludes for only one of the passed commands.

To configure excludes for individual commands, use the analysis_options.yaml configuration.

Uploading Results to DCM Dashboards​

To get an overview of all open issues and enabled code health metrics, and how they change over time, you can upload the results of this command to DCM Dashboards.

To get started, check out this guide.

Output Example​

Console (default)​

Use --reporter=console to get output in console format.

Console

JSON​

Use --reporter=json to get output as a single JSON object containing metadata and violations grouped by file.

Format specification

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 the "analyze" command results
  • metricResults - an array of the "calculate-metrics" command results
  • widgetResults - an array of the "analyze-widgets" command results
  • declarationName - an array of the "analyze-assets" command results
  • duplicationResults - an array of the "check-code-duplication" command results
  • unusedCodeResults - an array of the "check-unused-code" command results
  • unusedFilesResults - an array of the "check-unused-files" command results
  • unusedL10nResults - an array of the "check-unused-l10n" command results
  • dependenciesResults - an array of the "check-dependencies" command results
  • parametersResults - an array of the "check-parameters" command results
  • exportResults - an array of the "check-exports-completeness" command results
note

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

GitLab​

Use --reporter=gitlab to get output in a GitLab-compatible format. To learn how to integrate DCM with GitLab, refer to this guide.

Code Climate​

Use --reporter=codeclimate to get output in Code Climate format.

Output example
{"type":"issue","check_name":"prefer-match-file-name","description":"The first class name does not match the file name. Try renaming it.","categories":["Bug Risk"],"location":{"path":"lib/main.dart","positions":{"begin":{"column":7,"line":12},"end":{"column":12,"line":12}}},"severity":"critical","fingerprint":"99d316420d21b4c371325ad8d3092980"}
{"type":"issue","check_name":"proper-super-calls","description":"This 'super' call must come first.","categories":["Bug Risk"],"location":{"path":"lib/main.dart","positions":{"begin":{"column":5,"line":51},"end":{"column":23,"line":51}}},"severity":"critical","fingerprint":"5088440ac641ab4c3dc9e8282c95bab7"}

Checkstyle​

Use --reporter=checkstyle to get output in Checkstyle format.

Output example
<?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>
note

Checkstyle format is supported by Bitbucket. To learn how to integrate DCM with Bitbucket, refer to this guide.

Sonar​

Use --reporter=sonar to get output in SonarQube's generic format for external issues.

Output example
{
"rules": [
{
"cleanCodeAttribute": "LOGICAL",
"description": "To learn more, visit the documentation https://dcm.dev/docs/rules/common/prefer-match-file-name",
"engineId": "dcm",
"id": "prefer-match-file-name",
"impacts": [
{
"severity": "MEDIUM",
"softwareQuality": "RELIABILITY"
}
],
"name": "prefer-match-file-name"
},
{
"cleanCodeAttribute": "LOGICAL",
"description": "To learn more, visit the documentation https://dcm.dev/docs/rules/flutter/proper-super-calls",
"engineId": "dcm",
"id": "proper-super-calls",
"impacts": [
{
"severity": "MEDIUM",
"softwareQuality": "RELIABILITY"
}
],
"name": "proper-super-calls"
},
],
"issues": [
{
"effortMinutes": 2,
"primaryLocation": {
"filePath": "lib/main.dart",
"message": "The first class name does not match the file name. Try renaming it.",
"textRange": {
"endColumn": 12,
"endLine": 12,
"startColumn": 7,
"startLine": 12
}
},
"ruleId": "prefer-match-file-name"
},
{
"effortMinutes": 5,
"primaryLocation": {
"filePath": "lib/main.dart",
"message": "This 'super' call must come first.",
"textRange": {
"endColumn": 23,
"endLine": 51,
"startColumn": 5,
"startLine": 51
}
},
"ruleId": "proper-super-calls"
}
]
}