Skip to main content

Configuring Metrics

Metrics are one of the core building blocks of DCM. Metrics help you understand the complexity of your code and identify areas that may be difficult to maintain or test.

All metrics are configurable.

Enabling a Metric​

To enable a metric add its id to the metrics entry:

analysis_options.yaml
dart_code_metrics:
metrics:
cyclomatic-complexity: 20

Alternatively, the threshold can be set via the threshold entry:

analysis_options.yaml
dart_code_metrics:
metrics:
cyclomatic-complexity:
threshold: 20

Customizing Estimated Effort​

To change the estimated effort for a particular metric, set effort (in minutes):

analysis_options.yaml
dart_code_metrics:
metrics:
cyclomatic-complexity:
effort: 10
info

If you are setting custom estimated effort, don't forget to set threshold.

Excluding Files for All Metrics​

To exclude files from a metrics report, provide a list of glob patterns for ignored files:

analysis_options.yaml
dart_code_metrics:
exclude:
metrics:
- test/**
- lib/src/some_file.dart