Expand description
Import resolution: verify that every import in a file resolves against the declared dependencies and on-disk paths, without a full compile.
Unlike the cross-file pass, resolution is per file: an import references only
the manifests reachable from that file, so it is compatible with --diff.
To stay correct under caching, the per-file extraction (the list of
imports, extract_imports) is cached with the file content, while the
resolution (matching imports against manifests on disk, import_resolves)
re-runs on every scan. Editing a manifest to add a dependency therefore clears
a finding even when the importing file is unchanged.
Each language lives in its own module ([rust], [typescript]) implementing
[LanguageSupport]; [manifest] holds the shared manifest reading and
caching. This module dispatches on Language and turns unresolved imports
into findings.
Structs§
- File
Imports - What one file contributes to the resolution pass: its imports plus, for Rust,
the names it binds itself (
mod foo;,use crate::a::foo;,use a::b as foo;), which a bareuse foo::...in the same file may legitimately reference. - Import
Ref - One import reference found in a file, with the location to anchor a finding.
- Manifest
Resolver - Reads and memoizes the manifests governing scanned files. Single-threaded: the resolution pass runs after the parallel per-file scan. Keyed by the file’s directory, so files in the same directory reuse a parsed manifest.
- Resolution
Filter - Which files a resolution rule may report on, from its
files/ignoresglobs. Applied to the importing file.
Enums§
- Resolution
Kind - Resolution analyses a rule can request. Builtin only: a custom YAML may tune an existing kind’s severity or message, never invent a new one, so an unknown discriminant is a parse error.
Functions§
- evaluate_
file - Evaluate one resolution rule against a single file’s imports, emitting a
finding per unresolved import.
$importin the rule message is replaced with the offending specifier. - extract_
imports - Extract a file’s imports for the given language.
- import_
resolves - Whether a single import resolves, dispatching on the file’s language.