Skip to main content
Teams

Check Dependencies

Checks missing, under-promoted, over-promoted, and unused dependencies.

To execute the command, run:

$ dcm check-dependencies lib # or dcm d lib

Full command description:

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


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


-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}> File paths in Glob syntax to be exclude.
(defaults to "{**/*.g.dart,**/*.freezed.dart}")


--no-congratulate Don't show output even when there are no issues.


--verbose Show verbose logs.


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


--[no-]fatal-found Treat dependency issues as fatal.
(defaults to on)

Ignoring particular packages from the report

In order to ignore particular packages from the report, pass the --ignored-packages option to the CLI.

note

If freezed_annotation dependency is present, then build_runner and freezed are marked as used by default.

If json_serializable dependency is present, then build_runner is marked as used by default.

Output example

Console

Use --reporter=console to enable this format.

Console

JSON

The reporter prints a single JSON object containing meta information and the unused code file paths. 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
  • dependencyIssues - an array of dependency issues
{
"formatVersion": 1,
"timestamp": "2021-04-11 14:44:42",
"dependencyIssues": [
{
...
},
{
...
},
{
...
}
]
}

The dependencyIssues object fields are

  • path - a relative path of the unused file
  • issues - an array of issues detected in the target file
{
"path": "lib/src/some/file.dart",
"issues": [
...
],
}

The issue object fields are

  • message - the message associated with the issue
  • targetDependencyType - the type of the pubspec dependency (can be "regular" or "dev")
  • type - the type of the issue (can be "unused", "promotion" or "missing")
  • offset - a zero-based offset of the dependency location in the pubspec.yaml file
  • line - a zero-based line of the dependency location in the pubspec.yaml file
  • column - a zero-based column of the dependency location in the pubspec.yaml file
{
"message": "Dependency is unused",
"offset": 156,
"line": 7,
"column": 1,
"type": "unused",
"targetDependencyType": "regular"
}

GitLab

Reports dependency issues in merge requests based on Code Quality custom tool. Use --reporter=gitlab to enable this format.

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="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="some_package is not used" source="dependency-issue"/>
</file>
</checkstyle>