Expand description
alint-core — engine, walker, rule trait, config AST.
See docs/design/ARCHITECTURE.md in the alint repository for the
rule model, execution order, and crate layout rationale.
Re-exports§
pub use facts::FactKind;pub use facts::FactSpec;pub use facts::FactValue;pub use facts::FactValues;pub use facts::evaluate_facts;pub use when::WhenEnv;pub use when::WhenError;pub use when::WhenExpr;
Modules§
- did_
you_ mean - Did-you-mean suggestions for
RuleRegistry::builderrors. - facts
- Facts — cached properties of the repository evaluated once per run and
referenced by
whenclauses on rules (shipping in a later commit). - git
- Best-effort git-tracking integration.
- jsonpath_
diagnostics - Domain-specific hints for
JSONPathparse errors. - template
- String substitution for path templates and message templates.
- when
- The
whenexpression language — bounded DSL for gating rules on facts.
Macros§
- rule_
common_ impl - Stamp out the three boilerplate
Ruleimpl methods every rule kind ships:id,level,policy_url. Expects the impl’ing struct to have fields namedid: String,level: Level, andpolicy_url: Option<String>(the universal shape every rule builder hands back).
Structs§
- Compiled
Nested Spec - A
NestedRuleSpecwith itswhen:source pre-compiled into acrate::when::WhenExprat rule-build time. - Config
- Parsed form of a
.alint.ymlfile. - Context
- Execution context handed to each rule during evaluation.
- Engine
- Executes a set of rules against a pre-built
FileIndex. - File
Append Final Newline FixSpec - Empty marker. Behavior: if the file has content and does not
end with
\n, append one. - File
Append FixSpec - File
Collapse Blank Lines FixSpec - Empty marker. Behavior: collapse runs of blank lines longer than
the parent rule’s
maxdown to exactlymaxblank lines. - File
Create FixSpec - File
Entry - A single filesystem entry discovered by the walker.
- File
Index - The indexed result of one filesystem walk. All rules share this index —
the walk happens once per
alint checkinvocation. - File
Normalize Line Endings FixSpec - Empty marker. Behavior: rewrite the file with every line ending
replaced by the parent rule’s configured target (
lforcrlf). - File
Prepend FixSpec - File
Remove FixSpec - File
Rename FixSpec - Empty marker:
file_renametakes no parameters. The target name is derived from the parent rule (e.g.filename_caseconverts the stem to its configured case; the extension is preserved). - File
Strip Bidi FixSpec - Empty marker. Behavior: remove every Unicode bidi control character (U+202A–202E, U+2066–2069) from the file’s content.
- File
Strip BomFix Spec - Empty marker. Behavior: remove a leading UTF-8/UTF-16/UTF-32 BOM byte sequence if present; otherwise a no-op.
- File
Strip Zero Width FixSpec - Empty marker. Behavior: remove every zero-width character
(U+200B / U+200C / U+200D / U+FEFF) from the file’s content,
except a leading BOM (U+FEFF at position 0) — that’s the
responsibility of the
no_bomrule. - File
Trim Trailing Whitespace FixSpec - Empty marker. Behavior: read file (subject to
fix_size_limit), strip trailing space/tab on every line, write back. - FixContext
- Runtime context for applying a fix.
- FixItem
- FixReport
- Outcome of running
Engine::fixagainst a repository. OneFixRuleResultper rule that produced violations; rules that passed are omitted. - FixRule
Result - Nested
Rule Spec - Rule specification for nested rules (e.g. the
require:block offor_each_dir). UnlikeRuleSpec,idandlevelare synthesized from the parent rule — users just supply thekindplus kind-specific options, optionally with amessage/policy_url/when. - Report
- Rule
Entry - A rule bundled with an optional
whenexpression. Rules with awhenthat evaluates to false at runtime are skipped (noRuleResultis produced) — same observable effect aslevel: off, but gated on facts. - Rule
Registry - Map from
kindstring → factory function. Built-in rule crates register themselves here at startup, and plugin rules (in later phases) will too. - Rule
Result - The collected outcome of evaluating a single rule.
- Rule
Spec - YAML-level description of a rule before it is instantiated into a
Box<dyn Rule>by aRuleBuilder. - Scope
- Compiled include/exclude matcher built from a
PathsSpecor raw pattern list, optionally bundled with aScopeFilterancestor-manifest gate. - Scope
Filter - Per-file rule gate. Today’s only primitive is
has_ancestor; the type is an enum-shape struct so future primitives (closest_ancestor_with_content, etc.) can land without breaking the public surface. - Scope
Filter Spec - YAML-level shape of
scope_filter:. Deserialised byRuleSpecand validated into the runtimeScopeFilterviaScopeFilter::from_spec. - Violation
- A single linting violation produced by a rule.
- Walk
Options
Enums§
- Content
Source Spec - Pre-validated content source — exactly one of inline or from-file. Resolved at config-parse time so fixers don’t need to reproduce the XOR check at apply time.
- Error
- Extends
Entry - A single
extends:entry. Accepts either a bare string (the classic form — a local path,https://URL with SRI, oralint://bundled/<name>@<rev>) or a mapping that addsonly:/except:filters on the inherited rule set. - FixOutcome
- The result of applying (or simulating) one fix against one violation.
- FixSpec
- The
fix:block on a rule. Exactly one op key must be present — alint errors at load time when the op and rule kind are incompatible. - FixStatus
- GitTracked
Mode - How a rule narrows its iteration to git-tracked entries.
Returned by
Rule::git_tracked_mode; the engine reads this at construction time to pick the right pre-filteredFileIndex(file-only or dir-aware) for each opted-in rule. - Level
- Paths
Spec - YAML shape for a rule’s
paths:field — a single glob, an array (with optional!patternnegations), or an explicit{include, exclude}pair. For the include/exclude form, each field accepts either a single string or a list of strings. - Read
ForFix - Result of
read_for_fix— either the bytes of the file, or aFixOutcome::Skippedthe caller should return.
Traits§
- Fixer
- A mechanical corrector for a specific rule’s violations.
- PerFile
Rule - File-major dispatch entry-point for a per-file rule.
- Rule
- Trait every built-in and plugin rule implements.
Functions§
- check_
fix_ size - Check whether
absis within thefix_size_limitonctx. ReturnsSome(outcome)when the file is over-limit (the caller returns this directly); returnsNonewhen the fix can proceed. Emits a one-line stderr warning on over-limit. - eval_
per_ file - Rule-major fallback for
PerFileRuleimplementors. - read_
for_ fix - Read
abssubject to the size limit onctx. Over-limit files returnReadForFix::Skipped(Outcome::Skipped(_))and emit a one-line stderr warning; in-limit files returnReadForFix::Bytes(...). Pass-through I/O errors propagate. - reject_
scope_ filter_ on_ cross_ file - Build-time guard for cross-file rule builders. Cross-file
rules express ancestor scoping through
for_each_dir + when_iter:instead ofscope_filter:; the engine consults the per-file dispatch path’sScope::matches(which folds inscope_filtersince v0.9.10), so a cross-file rule withscope_filter:set would silently ignore the field. This helper produces a clear build-time error so the misconfiguration surfaces at config-load time rather than as a confused-rule-doesn’t-fire bug. - reject_
scope_ filter_ with_ reason - Build-time guard for rules whose evaluation target is fixed
(a hardcoded path or a tree-level invariant), making
scope_filter:semantically meaningless. Sister helper toreject_scope_filter_on_cross_file; used by rules likeno_submodules(hardcoded to.gitmodulesat the repo root) where the user-supplied filter has nothing to scope. - resolve_
content_ source - Resolution of an
(content, content_from)pair to a single content source. Used by the three fixers that take either. Errors when neither or both are set. - walk