Getting started
This guide runs both analyzers with their defaults and then adds a small project configuration.
1. Add Hyena to the project
Section titled “1. Add Hyena to the project”For Dart:
dart pub add dev:hyena_dartFor Flutter:
flutter pub add dev:hyena_dartHyena v2 is run through the project dependency. Every command below resolves the version pinned by this project.
2. Resolve the target package
Section titled “2. Resolve the target package”From the Dart or Flutter package you want to inspect:
dart pub getThis creates or updates .dart_tool/package_config.json, which dead-code analysis uses to resolve package export URIs.
3. Run both analyzers
Section titled “3. Run both analyzers”dart run hyena_dart analyze .The optional path is the first positional argument. If it is omitted, Hyena uses the current directory. Pointing at lib is useful when you do not want to include test and tool code:
dart run hyena_dart analyze libYou can also inspect one Dart file while iterating:
dart run hyena_dart analyze lib/src/cache.dartReported paths always start at the project root, not at the selected target. The two examples above therefore report files such as lib/src/cache.dart; a one-file run also reports that same project-relative path.
The console report contains:
- declaration and unused-entity counts;
- dead-code findings grouped by declaration type;
- file, function, and line totals;
- functions that exceed any configured complexity threshold.
4. Add a config
Section titled “4. Add a config”Create hyena.yaml in the package root:
hyena: exclude: - "**/fixtures/**" - "lib/src/platform/**"
complexity: cyclomatic_threshold: 15 max_nesting: 4 max_parameters: 6
dead_code: ignore_main: true ignore_exports: false ignore_private: falseRun the same command again. Hyena searches from the target directory upward and loads the first hyena.yaml or analysis_options.yaml it finds.
5. Write a reviewable report
Section titled “5. Write a reviewable report”dart run hyena_dart analyze lib \ --format=markdown \ --output=hyena-report.mdFor data processing or CI, choose JSON instead:
dart run hyena_dart analyze lib --format=json --output=hyena-report.jsonTo make findings enforceable without failing on existing debt, create a baseline once and commit it:
dart run hyena_dart analyze lib --write-baseline=hyena-baseline.jsondart run hyena_dart analyze lib \ --baseline=hyena-baseline.json \ --fail-on=dead-code,complexityRead the result correctly
Section titled “Read the result correctly”- A threshold is violated only when a metric is greater than its limit. A cyclomatic score of 20 does not violate the default threshold of 20.
- The CLI returns 0 for findings by default. Use
--fail-onto select which finding categories should return exit code 1. See CI and automation. - Unused public and private declarations are both reported by default in v2. Reusable package authors can preserve exported public API with
ignore_exports: trueor--ignore-exports. - Dead-code findings are static reachability results. Reflection, generated registration, and behavior outside the scanned source can require exclusions or manual review.
Next: use the CLI reference or read how dead-code reachability works.
