Core Concepts
This page contains a high-level overview of some of the core concepts of DCM.
What is DCM?
DCM (formerly Dart Code Metrics) is a toolkit that helps you identify and fix problems in your Dart and Flutter code. These problems can range from potential runtime bugs and violations of best practices to styling issues. DCM includes over 180 built-in rules to validate your code against various expectations, and you can customize these rules to fit your specific needs.
Rules
Rules are central to how DCM works. They are used to check whether your code meets certain expectations, and to specify what should be done if it doesn't. Rules can also be configured with additional options specific to that rule.
For more information, see the Rules documentation.
Assists
Assists are additional actions that help you refactor your code faster. They also also be configured with additional options to meet your needs.
For more information, see the Assists documentation.
Metrics
Metrics are another important aspect of DCM. They are used to measure the complexity of your code and identify areas that may be difficult to maintain or test. This can be particularly useful for larger projects, where it can be challenging to keep track of all the different contributions from various developers. Metrics can also provide instant feedback on pull requests for smaller projects, helping to ensure that code stays easy to maintain.
All metrics are configurable.
For more information, see the Metrics documentation.
Commands
In addition to providing rules, assists and metrics, DCM also includes commands to help with codebase maintenance, such as identifying unused code, unused files, and unused localization.
For more information, see the CLI documentation.
Configuration
DCM is designed to be flexible and configurable to fit your specific needs. You can choose to enable only metrics calculation, only rules, or both.
For more information, see the Configuration documentation.
DCM and Dart analyzer
While the Dart analyzer is also a static analysis tool that highlights problems in code, there are some key differences between it and DCM:
- DCM includes custom rules that are not included in the analyzer and linter tools.
- DCM's rules are more configurable and therefore more flexible.
- DCM provides metrics to measure codebase complexity and commands to help with codebase maintenance.
- DCM can add rules that you think are valuable and contradict with the Google style guide.
Using both tools as part of your development workflow can help ensure the quality of your code.
DCM and Copilot / ChatGPT
While Large Language Models can speed up the development process, their main focus is in quantity, not quality. And sometimes it's really hard to verify that the output of such model is actually valid.
For DCM it's not that important whether the code was written by a developer or Copilot, it will still analyze the code to find possible bugs, style issues and other problems.
If you want to maximize your productivity, you might want to use both.