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> The format of the output of the analysis.
[console (default), codeclimate, json, gitlab]
--json-path=<path/to/file.json> Path to the JSON file with the output of the analysis.


-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
  • 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
}

GitLab

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