FAQ
Why are my Flutter routes or router pages reported as unused?
Section titled “Why are my Flutter routes or router pages reported as unused?”Hyena does not automatically treat Flutter or router pages as live. A router, dependency-injection system, or plugin registry can reach declarations without a Dart reference Hyena can follow, so declare those roots in hyena.yaml:
hyena: dead_code: entry_points: - AppRoutes - ServiceRegistry.register entry_point_annotations: - RoutePageentry_points takes exact declaration names, either simple (AppRoutes) or qualified by owner (ServiceRegistry.register). Matched declarations become reachability roots, so everything they reference stays live. A matched type container, such as a class, also keeps its public members.
Both lists are empty by default. Add only entry mechanisms a router, DI system, or similar tool actually uses. See Framework and generated-code entry roots for the full matching rules.
Do I need to exclude generated code?
Section titled “Do I need to exclude generated code?”No. Files ending in .g.dart, .freezed.dart, or .mocks.dart, including part files, are handled automatically:
- Dead-code analysis collects references from them, so declarations used only by generated code stay reachable when reference collection succeeds, and never reports their own declarations.
- Complexity analysis skips them.
Generated files that fail resolution are silently ignored and can leave code used only by them reported as dead; see Analysis flow.
Do not list those suffixes in exclude unless you want the files removed entirely. A matching exclude pattern removes a generated file from analysis, including its references. Paths with a .dart_tool, build, or generated directory segment are still always excluded. See Generated files and dead-code generated files.
How does annotation matching work?
Section titled “How does annotation matching work?”entry_point_annotations marks annotated declarations as roots. A leading @ is optional, so RoutePage and @RoutePage are equivalent.
- A simple name matches the final component regardless of import prefix:
RoutePagematches@RoutePage()and@framework.RoutePage(). - A qualified name matches the exact prefix and name:
riverpod.Riverpodmatches@riverpod.Riverpod(), not@framework.Riverpod().
Matching is lexical, against the annotation as written in source. Hyena does not resolve the annotation’s type. See Annotation matching.
Why are public declarations in my package reported?
Section titled “Why are public declarations in my package reported?”ignore_exports defaults to false, so unused public declarations are findings like any other. Public visibility alone does not make a declaration reachable.
If you publish a reusable package whose public API is consumed outside the repository, enable export preservation:
hyena: dead_code: ignore_exports: trueOr pass --ignore-exports for a single run. Hyena then treats as roots the public declarations in directly importable lib/ libraries (any file not under lib/src/) and their part files, plus public declarations exposed by explicit export directives, honoring show and hide. Public members of those exported types are preserved too. See Export handling.
How do I suppress a single finding?
Section titled “How do I suppress a single finding?”Put a // hyena:ignore comment immediately before the declaration:
// hyena:ignore dead-codevoid registeredByName() {}
// hyena:ignore cyclomatic-complexity, max-nestingvoid stateMachine() {}The supported rules are dead-code, complexity, cyclomatic-complexity, max-nesting, and max-parameters. Separate multiple rules with commas. complexity covers all three complexity rules.
A declaration suppressed for dead-code remains a reachability root, so its dependencies do not become cascading findings. See Baselines and source suppressions, dead-code suppressions, and complexity suppressions.
Do I need to run dart pub get first?
Section titled “Do I need to run dart pub get first?”Yes. Dead-code analysis uses the official Dart analyzer and your package resolution, including .dart_tool/package_config.json. Run dart pub get, and code generation if you use it, before analysis:
dart pub getdart run hyena_dart analyze .Non-generated files that cannot be analyzed are skipped with Warning: skipped <path>: <reason> on stderr. Skipping is not a substitute for resolving the package: a skipped file’s declarations are not checked. Missing references can cause dead-code findings that trip --fail-on; see Analysis flow, Prepare the target, and Skipped files.
