Static analysis for Dart + Flutter

Find unused code. Measure the hard parts.

Hyena resolves your Dart AST to trace declaration reachability, then measures function-level complexity. Run it from the terminal, emit a report, or call the analyzers from Dart.

v2.0.0 · current release · Dart SDK 3.10.3+

hyena / report
$ dart run hyena_dart analyze lib --no-color

HYENA CODE ANALYSIS REPORT
────────────────────────────────
Target: lib

DEAD CODE
Total declarations: 204
Unused entities:     0
✓ No dead code detected

COMPLEXITY
Files:                 17
Functions:             251
Threshold violations: 5
dart pub add dev:hyena_dart

Safe AI / MCP

Introduced in v1.1.2

One bounded tool for AI-assisted review.

Run hyena_dart:hyena_mcp from the project that pins Hyena. --root . confines its one read-only tool to that project and relative Dart targets.

  • One analysis surface.hyena_analyze(path, checks) returns schema-versioned findings.
  • No execution path.No HTTP server, shell, target execution, writes, fixes, or outbound network code.
  • Bounded, not sandboxed.Path checks and hard limits apply; untrusted workspaces still need OS isolation.
Configure Safe AI / MCP
mcp.jsonstdio
{
  "mcpServers": {
    "hyena": {
      "command": "dart",
      "cwd": "/absolute/path/to/project",
      "args": [
        "run",
        "hyena_dart:hyena_mcp",
        "--root",
        "."
      ]
    }
  }
}
tool callhyena_analyze({ "path": "lib", "checks": "both" })

The short path

From install to report in three commands.

Use the defaults first. Add a config only when generated files, reusable public APIs, or your team's complexity limits need different treatment.

01 / Install

Pin it to the project

Add Hyena as a development dependency so local and CI runs use the same version.

dart pub add dev:hyena_dart
02 / Prepare

Resolve your package

Dead-code analysis needs analyzer resolution for every included file.

dart pub get
03 / Analyze

Choose a file or directory

Analyze the package, a subdirectory, or one Dart file while iterating.

dart run hyena_dart analyze .

Analysis surface

Two passes, one report.

Dead-code analysis follows resolved references from roots. Complexity analysis parses each function, method, constructor, and closure into a small set of reviewable metrics.

How analysis works

Reachability-based dead code

Reports declarations that cannot be reached from entry points, inherited implementations, top-level references, and configured roots.

  • classes
  • mixins
  • extensions
  • enums
  • constructors
  • methods
  • fields
  • typedefs

Function-level complexity

Measures control-flow paths, nesting, parameters, physical LOC, Halstead volume, and a normalized maintainability index.

  • cyclomatic
  • nesting
  • parameters
  • LOC
  • Halstead
  • MI

Predictable exclusions

Custom glob patterns apply on top of built-in exclusions for generated outputs and build directories.

  • *.g.dart
  • *.freezed.dart
  • *.mocks.dart
  • generated/
  • .dart_tool/
  • build/

Adoption controls

Keep exceptions explicit. Gate only what is new.

Source suppressions and a versioned baseline are applied before reporting and exit-code policy, so existing debt does not need a broad exclusion.

01 / Source

Suppress one declaration

Keep an intentional exception next to the code and scope it to a declaration or rule.

// hyena:ignore dead-code
02 / Baseline

Record accepted findings

Commit stable, line-independent fingerprints for findings the project accepts today.

--write-baseline=hyena-baseline.json
03 / CI

Fail on new findings

Apply the baseline, then return exit code 1 only for the selected finding categories.

--fail-on=dead-code,complexity

See baseline and CI examples

Output

Read it now or pass it on.

Every command can write to stdout or a file. The selected reporter changes presentation, not the analysis itself.

Default

Console

Compact summaries and the first 20 findings, with optional ANSI color.

Automation

JSON + SARIF

Structured metrics for custom policies and SARIF 2.1 for code-scanning systems.

Review

Markdown

Tables and collapsible file sections that fit issue and pull-request workflows.

Share

HTML

A standalone report with summary cards and detailed violation tables.

Operational notes

Know what the result means.

Hyena is a focused analyzer, not a replacement for the Dart compiler, lints, tests, or runtime coverage.

  • Resolve first. Dead-code analysis stops if an included Dart file has a resolution error.
  • Thresholds are strict. A value equal to its configured limit is allowed; only greater values are violations.
  • Public code is checked by default in v2. Reusable packages can preserve exported APIs explicitly with ignore_exports: true.
  • Dynamic dispatch stays conservative. Unresolved dynamic calls retain same-named members when the runtime target cannot be proven.

Documentation

Start with the defaults. Tune with evidence.