unused-files

Same as check-unused-files in Dart Code Metrics

Path
cross-file/correctness/unused-files
Default
Off, opt in
Origin
Dart Code Metrics
Rule
481 of 512
cross-file

Cross-file rule. It runs in falcon's whole-project pass, analyzing relationships across every file rather than one file at a time. Configure it under the top-level cross-file key.

Report lib/ files that no project entrypoint can reach.

Models the file set as a directed graph (file → every file its imports/exports/parts reference) and flags a lib/src/** file when no entrypoint reaches it. Entrypoints ("roots") are: any analyzed file outside lib/ (bin/test/tool/example, or their own concern), any file declaring a top-level main, and the public library surface — every lib/ file not under lib/src/, which external packages may import (this subsumes the lib/<pkg>.dart barrel). Reachability, not mere reference count, is the test: a cluster of lib/src files that reference only each other but that nothing live reaches is dead and is flagged. part of files belong to their owning library and are never flagged directly. Without a pubspec the scope narrows to files with a lib/ path component and the public-surface exemption is not applied (no lib/ root is known). This is a cross-file rule: it runs in the cross-file pass and is configured under the top-level cross-file section.

Invalid

bad/lib/src/orphan.dartdart
void orphan() {}
bad/lib/src/orphan.dartFile is not reachable from any entrypoint (main, a non-lib file, or the public library surface); it may be dead code.
1void orphan() {}

Configure unused-files

Set its severity in falcon.json under the cross-file section. See the configuration guide.

falcon.jsonjson
{
  "cross-file": {
    "rules": {
      "correctness": {
        "unused-files": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore cross-file/correctness/unused-files: <reason>