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§

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.
template
String substitution for path templates and message templates.
when
The when expression language — bounded DSL for gating rules on facts.

Structs§

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.
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
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.
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.
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.
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