DCM (Dart Code Metrics)
website·Indexed 33 days ago
https://dcm.dev/A static analysis tool for Dart and Flutter that provides code metrics, unused code detection, and a comprehensive set of rules to improve code quality. It includes features such as a 'Recommended' preset, a Teams Console, and specialized commands like 'analyze-widgets' and 'check-dependencies'. DCM supports Dart 3.0 and integrates with CI/CD pipelines and GitHub Actions.
What's inside DCM
- Static analysis in Flutter is the process of examining code for errors and style issues without executing the app. It uses the Dart Analyzer to convert source code into an Abstract Syntax Tree (AST) and validate it against defined rules. Linting is a specific subset of static analysis that focuses on style and best-practice rules to ensure code follows the Dart style guide and Effective Dart recommendations.
Overview of DCM (Dart Code Metrics) capabilities
DCM (formerly Dart Code Metrics) is a local analysis toolkit for Dart and Flutter designed to improve code quality and maintainability. It provides the following core capabilities:
- Static Analysis: Over 530 customizable rules to detect runtime bugs, performance issues, and styling inconsistencies, including specialized rules for packages like
provider,bloc, andriverpod. - Code Metrics: Calculation of complexity and Flutter widget quality metrics to monitor codebase health and set quality thresholds.
- Refactoring & Cleanup: Tools for detecting unused code, duplicate code, unused localization, and misused dependencies.
- Flutter-Specific Analysis: Specialized analysis to detect duplicate widgets and partially matching subtrees.
- Developer Workflow: Provides IDE quick-fixes, auto-fixes, and a 'Baseline' feature that allows users to ignore existing violations and only show warnings for new code.
- Integration: Supports VS Code, Android Studio, and IntelliJ IDEA, as well as CI/CD pipelines (GitHub, GitLab, Bitbucket, Azure).
- Privacy: All analysis is performed fully locally; code is never sent to a remote server.
- Static Analysis: Over 530 customizable rules to detect runtime bugs, performance issues, and styling inconsistencies, including specialized rules for packages like
Overview of DCM Dashboards
DCM Dashboards is a feature within the DCM Teams Console that provides a high-level overview of open issues (from lint rules and code quality commands) and metrics. It allows organizations to create multiple projects (representing single packages or mono-repos) to track the following:
- Projects Overview: High-level summary of all active projects.
- Issues Overview: Breakdown of issues by category with estimated fix times and monthly trends.
- Open Issues Over Time: Visualization of issue counts over 7, 14, 30, or 90-day intervals.
- Baselined Issues Over Time: Tracking of issues added to the baseline (currently supporting lint rules) to help reduce technical debt to zero.
- Metrics: Charts for enabled project metrics showing min, max, avg, sum, and violation counts.
Overview of DCM MCP Server capabilities
The DCM MCP Server (available for DCM 1.31.0+) allows MCP-compatible clients using
stdiotransport to perform advanced Flutter and Dart project operations. To utilize all features, the client must support Tools and Roots capabilities. If a client claims to support roots but does not set them, use the--force-roots-fallbackflag.Key capabilities include:
- Analyzing and fixing code errors
- Applying fixes for unused code, unused files, and dependency issues
- Formatting code and generating baselines
- Generating previews for lint rules and metrics
- Calculating metrics and running code quality checks
- Analyzing Flutter widgets and image assets.
Overview of DCM MCP Server capabilities
The DCM MCP Server (available for DCM 1.31.0+) allows MCP-compatible clients to perform advanced Flutter and Dart project operations. It uses
stdioas the transport medium and requires support for Tools and Roots capabilities. If a client claims to support roots but does not set them, use the--force-roots-fallbackflag to enable root management tools.Key capabilities include:
- Analyzing and fixing code errors
- Applying fixes for unused code, unused files, and dependency issues
- Formatting code and generating baselines
- Calculating metrics and generating previews for lint rules
- Running code quality checks
- Analyzing Flutter widgets and image assets
Overview of DCM Dashboards for Teams+
DCM Dashboards provide an overview of all open issues (derived from lint rules and code quality checks) and metric violations across all projects. It allows teams to track how these numbers change over time.Overview of DCM Dashboards
DCM Dashboards allow organizations to monitor issues, metrics, and code quality trends over time. It provides a visualization of technical debt and tracks how it changes across multiple projects. Key capabilities include an aggregated health check for the entire organization and detailed views for individual projects.Overview of DCM benefits for Dart and Flutter development
DCM (Dart Code Metrics) is a tool designed to improve software quality and developer productivity in Dart and Flutter projects. It automates the detection of bugs, stylistic inconsistencies, and technical debt, allowing teams to focus on feature delivery rather than manual code maintenance. Key benefits include:
- Early Issue Detection: Identifies common and hard-to-spot mistakes to prevent runtime errors and performance issues.
- Efficient Code Reviews: Automates checks for simple mistakes and style issues, reducing the number of review iterations.
- Consistency & Onboarding: Enforces uniform code style across multiple projects and helps new team members adapt to project standards quickly.
- Technical Debt Management: Reduces long-term project costs by ensuring code adheres to maintainable standards.
- Rapid Refactoring: Provides commands to quickly identify unused or duplicate code, reducing refactoring time from hours to minutes.
- Ecosystem Alignment: Helps teams automatically adopt the latest changes and features in the evolving Dart and Flutter ecosystem.
Overview of the Flutter Widget Previewer
The Flutter Widget Previewer is a design canvas that isolates widgets, rendering them in real-time decoupled from the main app UI. It allows developers to visualize multiple variations of a widget (e.g., different themes, screen sizes, and states) side-by-side without navigating through the app's full flow. It is particularly useful for building design systems and verifying UI across different configurations without the 'navigation tax' of standard Hot Reload.Overview of DCM Dashboards
DCM Dashboards provide a centralized view of open issues and metrics, tracking how code quality changes over time. It is available for Teams and Enterprise users. Key features include:
- Projects Overview: High-level summary of active projects (single packages or monorepos).
- Issues Overview: Breakdown of issues by category with estimated time to fix.
- Open Issues Over Time: Charts showing issue trends over specific intervals (e.g., 7 or 30 days).
- Metrics: Summary view of all enabled metrics.
- Printable Reports: Ability to export dashboards as PDFs for stakeholders.
- Access Control: Support for a "View Selected" role for granular project access and external user invites.
Overview of SemanticsRole options in Flutter 3.32
TheSemanticsRoleenum provides a variety of roles to describe the purpose of a widget to accessibility tools. Common roles includetab,dialog,searchBox,progressBar,status, andalert.enum SemanticsRole { none, tab, tabBar, tabPanel, dialog, alertDialog, table, cell, row, columnHeader, searchBox, dragHandle, spinButton, comboBox, menuBar, menu, menuItem, menuItemCheckbox, menuItemRadio, list, listItem, form, tooltip, loadingSpinner, progressBar, hotKey, radioGroup, status, alert, }Overview of the Flutter Widget Previewer
The Flutter Widget Previewer (introduced in Flutter 3.35) allows developers to render widgets in real-time in a dedicated design canvas, decoupled from the main app UI. It functions similarly to SwiftUI's canvas or Jetpack Compose previews, enabling the visualization of multiple widget variations (e.g., light/dark mode, different screen sizes, and error states) side-by-side without navigating through the app's full flow.