Getting Started with DCM
DCM is a tool that helps improve the quality and consistency of Dart code by identifying and reporting problems, such as bugs and code that doesn't follow best practices. It also collects analytical data on the code through calculating code metrics and can be configured to set thresholds for these metrics.
Installation
To use DCM, add it as a dev dependency to your project:
- Flutter
- Dart
$ flutter pub add --dev dart_code_metrics
$ dart pub add --dev dart_code_metrics
Usage
CLI
You can run DCM analysis from the console using the following command:
- Flutter
- Dart
$ flutter pub run dart_code_metrics:metrics analyze lib
$ dart run dart_code_metrics:metrics analyze lib
DCM also provides other commands such as check-unused-code
and check-unused-files
that can help you maintain the codebase. For more information on using DCM as a command-line tool, see the Command Line Interface documentation.
Analyzer plugin
DCM can be used as a plugin for the Dart analyzer, providing instant feedback on found issues directly in your integrated development environment (IDE). For more information on using DCM as an analyzer plugin, see the Analyzer Plugin documentation.
Library (additional option)
You can use DCM as a library directly in your code. See this example for more information. This might be useful if you have a separate package for linting config and want to run DCM from that package's executable.
Next Steps
- Learn about the configuration options for customizing DCM's behavior.
- Get familiar with the Command Line Interface for running DCM from the console.
- Explore DCM's GitHub Action and Codemagic integrations for running DCM as part of your continuous integration pipeline.