cognitive_complexity library
A deterministic, algorithmic Cognitive Complexity calculation library and CLI tool for Dart and Flutter.
Supports modern Dart 3 features including switch expressions, pattern
guards (when clauses), and declarative collection control flow elements.
Also provides standard Git diff historical evaluation and GitHub Actions
diagnostic reporting capabilities.
Classes
- ComplexityAnalyzer
- Analyzes Dart files and directories to compute Cognitive Complexity scores.
- ComplexityDelta
- Represents the comparison between historical and current complexity scores.
- DeltaAnalyzer
- Evaluates git diffs to calculate cognitive complexity score deltas.
- DeltaSummary
- Summarizes cognitive complexity delta metrics across a repository evaluation.
- FunctionComplexity
- Represents the analyzed cognitive complexity of a specific declaration.
- GitDiffService
- A service wrapping Git commands for repository evaluation and diffing.
- GitHubReporter
- Formats and emits diagnostic reports specifically for GitHub Actions CI/CD.
Enums
- DeltaStatus
- Describes the delta trajectory of a function's cognitive complexity score.
Functions
-
isExcludedPath(
String relativePath) → bool -
Whether
relativePathsits inside a directory that should never be scanned (.dart_tool,.git, orbuildoutput).