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.

v1.2.1 · Dart SDK 3.10+ · MIT licensed · local-first

hyena / report
$ 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 global activate hyena_dart

Safe AI / MCP

Introduced in v1.1.2

One bounded tool for AI-assisted review.

Start hyena_mcp with one absolute project root. An MCP client receives exactly one read-only tool for relative Dart paths and selected checks.

  • 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": "hyena_mcp",
      "args": [
        "--root",
        "/absolute/project"
      ]
    }
  }
}
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, public exports, or your team's complexity limits need different treatment.

01 / Install

Activate the CLI

Install the published executable into your Dart global cache.

dart pub global activate 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.

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 public API 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 common generated Dart outputs and generated directories.

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

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.
  • Exports are conservative by default. Directly importable libraries, parts, and every conditional branch are treated as reachable.
  • 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.