Skip to main content

Step 4: Integration

Enabling DCM Rules​

To quickly start using DCM rules, enable the "recommended" preset in your analysis_options.yaml file. This preset includes a curated set of rules designed to provide immediate benefits without extensive configuration.

Add the following to your analysis_options.yaml file:

dart_code_metrics:
extends:
- recommended

To find out more about presets, refer to the presets documentation on Presets.

Enabling DCM Metrics​

To quickly start using DCM metrics, install the dart_code_metrics_presets package and enable the metrics_recommended preset.

To find out how to enable a preset, refer to the presets documentation on Enabling a preset.

Excluding Existing Issues from the Analysis​

DCM offers a command to generate a baseline file with all existing issues. These issues will not be reported by the IDE or CLI, allowing you to address them gradually without overwhelming your development process.

To generate the baseline, use the following command:

dcm init baseline lib # or dcm i b lib

For more details, refer to the command documentation on generating the baseline.

Once the baseline file is created, you can incrementally remove the issues from this file and fix them at your own pace.

Additional Integration Techniques​

There are other techniques available to integrate DCM smoothly into your project. You can learn more about these methods in this comprehensive guide on Integrating DCM Into an Existing Project.