Skip to main content

Module resolution

Module resolution 

Source
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§

FileImports
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 bare use foo::... in the same file may legitimately reference.
ImportRef
One import reference found in a file, with the location to anchor a finding.
ManifestResolver
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.
ResolutionFilter
Which files a resolution rule may report on, from its files / ignores globs. Applied to the importing file.

Enums§

ResolutionKind
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. $import in 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.