Skip to main content

Crate alint_core

Crate alint_core 

Source
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::build errors.
facts
Facts — cached properties of the repository evaluated once per run and referenced by when clauses on rules (shipping in a later commit).
git
Best-effort git-tracking integration.
jsonpath_diagnostics
Domain-specific hints for JSONPath parse errors.
template
String substitution for path templates and message templates.
when
The when expression language — bounded DSL for gating rules on facts.

Macros§

rule_common_impl
Stamp out the three boilerplate Rule impl methods every rule kind ships: id, level, policy_url. Expects the impl’ing struct to have fields named id: String, level: Level, and policy_url: Option<String> (the universal shape every rule builder hands back).

Structs§

CompiledNestedSpec
A NestedRuleSpec with its when: source pre-compiled into a crate::when::WhenExpr at rule-build time.
Config
Parsed form of a .alint.yml file.
Context
Execution context handed to each rule during evaluation.
Engine
Executes a set of rules against a pre-built FileIndex.
FileAppendFinalNewlineFixSpec
Empty marker. Behavior: if the file has content and does not end with \n, append one.
FileAppendFixSpec
FileCollapseBlankLinesFixSpec
Empty marker. Behavior: collapse runs of blank lines longer than the parent rule’s max down to exactly max blank lines.
FileCreateFixSpec
FileEntry
A single filesystem entry discovered by the walker.
FileIndex
The indexed result of one filesystem walk. All rules share this index — the walk happens once per alint check invocation.
FileNormalizeLineEndingsFixSpec
Empty marker. Behavior: rewrite the file with every line ending replaced by the parent rule’s configured target (lf or crlf).
FilePrependFixSpec
FileRemoveFixSpec
FileRenameFixSpec
Empty marker: file_rename takes no parameters. The target name is derived from the parent rule (e.g. filename_case converts the stem to its configured case; the extension is preserved).
FileStripBidiFixSpec
Empty marker. Behavior: remove every Unicode bidi control character (U+202A–202E, U+2066–2069) from the file’s content.
FileStripBomFixSpec
Empty marker. Behavior: remove a leading UTF-8/UTF-16/UTF-32 BOM byte sequence if present; otherwise a no-op.
FileStripZeroWidthFixSpec
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_bom rule.
FileTrimTrailingWhitespaceFixSpec
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::fix against a repository. One FixRuleResult per rule that produced violations; rules that passed are omitted.
FixRuleResult
NestedRuleSpec
Rule specification for nested rules (e.g. the require: block of for_each_dir). Unlike RuleSpec, id and level are synthesized from the parent rule — users just supply the kind plus kind-specific options, optionally with a message / policy_url / when.
Report
RuleEntry
A rule bundled with an optional when expression. Rules with a when that evaluates to false at runtime are skipped (no RuleResult is produced) — same observable effect as level: off, but gated on facts.
RuleRegistry
Map from kind string → factory function. Built-in rule crates register themselves here at startup, and plugin rules (in later phases) will too.
RuleResult
The collected outcome of evaluating a single rule.
RuleSpec
YAML-level description of a rule before it is instantiated into a Box<dyn Rule> by a RuleBuilder.
Scope
Compiled include/exclude matcher built from a PathsSpec or raw pattern list, optionally bundled with a ScopeFilter ancestor-manifest gate.
ScopeFilter
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.
ScopeFilterSpec
YAML-level shape of scope_filter:. Deserialised by RuleSpec and validated into the runtime ScopeFilter via ScopeFilter::from_spec.
Violation
A single linting violation produced by a rule.
WalkOptions

Enums§

ContentSourceSpec
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
ExtendsEntry
A single extends: entry. Accepts either a bare string (the classic form — a local path, https:// URL with SRI, or alint://bundled/<name>@<rev>) or a mapping that adds only: / 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
GitTrackedMode
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-filtered FileIndex (file-only or dir-aware) for each opted-in rule.
Level
PathsSpec
YAML shape for a rule’s paths: field — a single glob, an array (with optional !pattern negations), or an explicit {include, exclude} pair. For the include/exclude form, each field accepts either a single string or a list of strings.
ReadForFix
Result of read_for_fix — either the bytes of the file, or a FixOutcome::Skipped the caller should return.

Traits§

Fixer
A mechanical corrector for a specific rule’s violations.
PerFileRule
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 abs is within the fix_size_limit on ctx. Returns Some(outcome) when the file is over-limit (the caller returns this directly); returns None when the fix can proceed. Emits a one-line stderr warning on over-limit.
eval_per_file
Rule-major fallback for PerFileRule implementors.
read_for_fix
Read abs subject to the size limit on ctx. Over-limit files return ReadForFix::Skipped(Outcome::Skipped(_)) and emit a one-line stderr warning; in-limit files return ReadForFix::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 of scope_filter:; the engine consults the per-file dispatch path’s Scope::matches (which folds in scope_filter since v0.9.10), so a cross-file rule with scope_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 to reject_scope_filter_on_cross_file; used by rules like no_submodules (hardcoded to .gitmodules at 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

Type Aliases§

Result
RuleBuilder