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

パッケージ詳細v5.1.0

dependency_validator

欠落している、不十分にプロモートされた、過剰にプロモートされた、および使用されていない依存関係を確認します。

macOSWindowsLinux
30日間ダウンロード
32.2万
いいね数
286
Pub ポイント
110

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

flutter pub add dependency_validator

パッケージ概要

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

プロジェクトの依存関係を分析して、欠落している、不十分に昇格された、過剰に昇格された、および使用されていない依存関係を特定するFlutter/Dart開発者向けツールです。ビルドエラーまたは膨張したパッケージを引き起こす可能性のある問題をマークすることで、クリーンで効率的なpubspec.yamlファイルの維持を支援します。シンプルなコマンドラインインターフェースを通じて、開発ワークフローにスムーズに統合されます。複雑な依存関係ツリーを持つ大規模なコードベースを管理するチームにとって特に有用です。Workivaによって開発され、macOS、Windows、Linuxプラットフォームをサポートしています。

用途

  • pubspec.yaml の正確性を保証する
  • 使用されていない依存関係の検出
  • 欠落した依存関係によるビルドの失敗を防ぐ
  • チームプロジェクトにおける依存関係の衛生管理
  • 誤った依存関係のプロモーションレベルの特定

主な機能

  • リアルタイム依存関係分析
  • 複数のプラットフォームをサポートしています
  • シンプルな CLI インテグレーション
  • 問題レポートのクリア
  • オープンソース、パブリックリポジトリ

適している対象

  • Flutter開発者
  • チームプロジェクトのメンテナー
  • CI/CDパイプライン統合者
  • 大規模なDartアプリケーション
  • コード品質の提唱者

注意事項

  • 手動実行または CI のセットアップが必要です
  • 複雑な依存関係構造のための設定が必要になる可能性があります
  • 包括的なテストの代替ではありません
  • 依存関係の検証のみに制限
  • 正しい pubspec.yaml 構文に依存しています

元の README

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

Dependency Validator

A tool to help you find missing, under-promoted, over-promoted, and unused dependencies.

Installation

dart pub global activate dependency_validator

Usage

dart pub global run dependency_validator

This will report any missing, under-promoted, over-promoted, and unused dependencies. Any package that either provides an executable or a builder that will be auto-applied via the dart build system will be considered used even if it isn't imported.

  • Missing: When a dependency is used in the package but not declared in the pubspec.yaml
  • Under-promoted: When a dependency is used within lib/, bin/, or hook/ but only declared as a dev_dependency.
  • Over-promoted: When a dependency is only used outside lib/, bin/, and hook/ but declared as a dependency.
  • Unused: When a dependency is not used in the package but declared in the pubspec.yaml.

Hook scripts in hook/ (for example, build.dart and link.dart) run at build/link time (dart build, flutter build), so their imports must be regular dependencies. To opt out, use ignore to suppress warnings for a specific package name (for example, a dev_dependency used only in hooks), or exclude: ["hook/**"] to skip scanning the hook directory entirely (which also skips missing-dependency checks in hook files).

Configuration

There may be packages that are intentionally depended on but not used, or there may be directories that need to be ignored. You can statically configure these things in a dart_dependency_validator.yaml file in the root of your package:

# dart_dependency_validator.yaml

# Set true if you allow pinned packages in your project.
allow_pins: true
# Exclude one or more paths from being scanned. Supports glob syntax.
exclude:
  - "app/**"
# Ignore one or more packages.
ignore:
  - analyzer

[!Note] Previously this configuration lived in the pubspec.yaml, but that option was deprecated because pub publish warns about unrecognized keys.

Pub Workspaces (monorepos)

This package supports Pub Workspaces, a collection of packages in one repository. Workspaces allow Pub to share dependencies between your packages. Your top-level package's pubspec.yaml should have a workspace field that indicates which sub-packages should be included, like this:

workspace:
  - pkg1
  - pkg2

and your sub-packages should have resolution: workspace in their pubspec.yamls. For more information, see the linked documentation.

Running dependency_validator will always validate the package your terminal is in. If you run the tool on the top-level workspace package, it will analyze the workspace package and its sub-packages. To just analyze a sub-package, run the tool in its folder, or pass the -C argument:

$ dart run dependency_validator -C pkg1

カテゴリー

依存関係

依存関係一覧 13 件

ソースリポジトリ

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