パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.2.0

dart_code_metrics_annotations

DCM の注釈。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.6万
いいね数
4
Pub ポイント
140

パッケージをインストール

flutter pub add dart_code_metrics_annotations

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Dart Code Metrics (DCM) と連携して使用されるように設計されたアノテーションのセットで、コード解析用のメタデータを提供します。これらのアノテーションは、特定のルールを無視したり、カスタムメトリクスを指定したりするなど、コードの特定部分を強化された検査対象としてマークするのに開発者を支援します。このパッケージは、複数のプラットフォームにおけるFlutterおよびDartプロジェクトにシームレスに統合され、静的解析に対するより正確な制御を可能にします。構成可能なディレクティブを通じて、lintingおよびコード品質の強制をサポートしています。

用途

  • lint ルールの動作をカスタマイズする
  • コード品質チェックの強化
  • CI/CD パイプラインとの統合
  • 特別な分析用にコードセクションをマークする
  • チーム全体のコーディング規範をサポート
  • 構造化されたアノテーションによる保守性の向上

主な機能

  • DCM 固有のアノテーションを提供します
  • 分析の細かな制御を可能にする
  • 既存の linter 設定と互換性があります
  • マルチプラットフォームプロジェクトをサポートしています
  • 自動化されたコードレビューを促進する
  • メトリクスベースのコードガバナンスを簡略化

適している対象

  • Dart および Flutter チームが DCM を使用しています
  • 厳格なコード品質基準を必要とするプロジェクト
  • 自動化されたLintingを備えたCI/CD環境
  • カスタマイズ可能な分析ルールを求める開発者
  • 一貫したコーディング慣習を遵守するチーム
  • 長期的な保守性を目指すプロジェクト

注意事項

  • Dart Code Metrics のインストールが必要です
  • 注釈はDCMと併用された場合にのみ効果があります
  • .analysis_options での設定の更新が必要になる場合があります
  • スタンドアロンではない—より大きなツールチェーンに依存しています
  • 分析ワークフローへの統合がなければ、利用価値は限定的です
  • 他のコード品質ツールと併用するのが最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Pub Version License package publisher

DCM Annotations

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.

@Throws()

Used to annotate getters, methods, functions, parameters or local variables that can throw an exception (or multiple exceptions/errors) and therefore an invocation of such declarations must explicitly handle that exception.

For example:

@Throws()
void fn() { /* ... */ }

@Throws({IndexError})
void anotherFn() { /* ... */ }

void main() {
  try {
    fn(); // OK.
  } catch(_) {}

  fn(); // LINT.

  try {
    anotherFn(); // OK.
  } catch(_) {}

  try {
    anotherFn(); // LINT.
  } on Exception catch(_) {}
}

DCM will provide feedback if:

  • an invocation of a declaration with this annotation has unhandled exceptions
  • a declaration is not marked with this annotation, but can throw an exception
  • a declaration is marked with this annotation, but does not have any invocation that throws an exception

For more information, see the documentation for handle-throwing-invocations and prefer-correct-throws.

@AcceptedTypes()

Used to annotate fields or parameters that have a type Object, but should only receive a known subset of types (e.g. String and int).

For example:

void fn() {
  fn(1); // LINT
  SomeClass(false); // LINT
}

void fn(@AcceptedTypes({String, bool}) Object value) {}

class SomeClass {
  @AcceptedTypes({String, int})
  final Object field;

  const SomeClass(this.field);
}

DCM will provide feedback if an invocation receives an argument that does not match the type listed in the @AcceptedTypes().

For more information, see the documentation for pass-correct-accepted-types.

@mutated

Used to annotate parameters or variables that are changed/updated within the function/method body.

For example, the avoid-collection-mutating-methods and avoid-mutating-parameters rules will not trigger on annotated parameters and avoid-not-assignable-collection-types will include such parameters into its analysis.

DCM will provide feedback if the @mutated annotation is missing or unnecessary.

For more information, see the documentation for prefer-correct-mutated and other rules mentioned above.

How to use annotations

Take these steps to use annotations:

  1. Install this package as a regular dependency:

    dart pub add dart_code_metrics_annotations
    

    or:

    flutter pub add dart_code_metrics_annotations
    
  2. Enable rules that rely on DCM annotations and add those annotations to your code.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト