搜索插件、代码仓与 APP 分类

插件详情v2.34.0

dart_code_metrics_presets

DCM 的预设配置,一个用于 Flutter 开发团队的代码质量工具。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
11.8万
喜欢数
39
Pub 分数
150

安装插件

flutter pub add dart_code_metrics_presets

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Dart Code Metrics (DCM) 是一款旨在帮助 Flutter 开发团队保持一致编码标准的代码质量工具。该集合包含一系列预定义的配置预设,为不同项目类型和团队偏好提供即用型规则集,简化了代码风格、复杂性和可维护性最佳实践的设置与执行。通过与 DCM 集成,团队可以快速应用行业对齐的规范,无需手动配置。该包支持所有主要平台,非常适合跨平台 Flutter 项目。

适合场景

  • 在团队间强制执行一致的代码风格
  • 在CI/CD流水线中自动化代码质量检查
  • 通过标准化规则引导新开发人员
  • 在大型Flutter应用中提高代码可维护性
  • 自定义适用于特定项目需求的 linting 规则

主要特点

  • 预定义的、经过实战检验的预设
  • 通过 pub add 轻松集成
  • 支持所有 Flutter 平台
  • 遵循 Dart 和 Flutter 最佳实践
  • 可扩展以进行自定义配置

适合对象

  • Flutter 团队优先考虑代码质量
  • 需要自动化 linting 的 CI/CD 环境
  • 需要快速设置的新 Flutter 项目
  • 采用标准化编码规范的团队
  • 寻求最小配置开销的开发者

使用建议

  • 需要安装 Dart Code Metrics
  • 预设可能需要根据特定项目需求进行调整
  • 不是独立的 linter;依赖 DCM 运行时
  • 预设定义内的自定义有限
  • 最好与团队范围的文档一起使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Pub Version License package publisher

DCM Presets

DCM is an advanced linter for Dart and Flutter that helps you analyze and improve your code quality. You can find all available lint rules here.

This repository contains a list of predefined DCM presets for lints:

  • All: contains all available lint rules for Dart and Flutter.
  • Recommended: contains recommended Dart and Flutter rules (with an emphasis on finding errors).
  • Dart: contains all lint rules applicable to any Dart app.
  • Flutter: contains all lint rules applicable to any Flutter app.
  • Pub: contains all lint rules for linting the pubspec.yaml files.
  • Flame: contains all lint rules for the Flame package.
  • Provider: contains all lint rules for the Provider package.
  • Bloc: contains all lint rules for the Bloc package.
  • Riverpod: contains all lint rules for the Riverpod package.
  • Equatable: contains all lint rules for the Equatable package.
  • Patrol: contains all lint rules for the Patrol package.
  • FakeAsync: contains all lint rules for the FakeAsync package.
  • Mocktail: contains all lint rules for the Mocktail package.
  • GetIt: contains all lint rules for the GetIt package.
  • JsonSerializable: contains all lint rules for the JsonSerializable package.
  • FlutterHooks: contains all lint rules for the FlutterHooks package.
  • FirebaseAnalytics: contains all lint rules for the FirebaseAnalytics package.
  • GetX: contains all lint rules for the GetX package.
  • Intl: contains all lint rules for the Intl package.
  • EasyLocalization: contains all lint rules for the EasyLocalization package.

and for metrics:

  • All Metrics: contains all available metrics with recommended default thresholds.
  • Recommended metrics: contains recommended metrics with default thresholds.

How to use a preset

Take these steps to enable a preset:

  1. Install this package as a dev dependency:

    dart pub add --dev dart_code_metrics_presets
    

    or:

    flutter pub add --dev dart_code_metrics_presets
    
  2. For DCM configuration add the extents entry:

    dart_code_metrics:
      extends:
        - package:dart_code_metrics_presets/all.yaml
    

Disabling or reconfiguring a rule from the preset

To disable a rule, simply set its value to false:

dart_code_metrics:
  extends:
    - package:dart_code_metrics_presets/all.yaml
  rules:
    - avoid-banned-imports: false

To reconfigure a rule, that is included into a preset:

dart_code_metrics:
  extends:
    - package:dart_code_metrics_presets/all.yaml
  rules:
    - arguments-ordering:
        child-last: true

Defining a custom preset

Any other preset can be passed to the extends entry. To create a custom preset create a yaml file with the same structure as for regular DCM configuration.

所属分类

源码仓库

使用此插件的项目