Skip to main content

Module checks

Module checks 

Source
Expand description

Custom config-defined checks ([rules.checks.<id>]) — a config-only linter primitive.

A CheckDef pairs a CEL boolean when predicate with a diagnostic message. The predicate is evaluated per node over everything the node carries: its numeric / boolean / string attributes (tloc, unsafe, cyclomatic, …) plus derived path strings (path, name, stem, ext, dir). String predicates use CEL’s own stdlib (contains, startsWith, endsWith, matches regex, size, double, …); on top of it we register only the graph-aware functions (depends_on / depended_on_by / file_exists). When the predicate is true, the check fires and produces a CheckHit the CLI turns into a violation.

This is what lets a project express a custom linter — e.g. “no inline tests in a production file” (tloc > 0 && !path.endsWith("_tests.rs")) — entirely in code-ranker.toml, with no Rust change. It complements [rules.thresholds.file] (which only does metric > limit) with an arbitrary boolean expression and a path-aware, string-aware context.

Structs§

CheckCompileError
A when predicate that failed to compile (reported up-front, so the gate fails loudly instead of silently skipping a misspelled check).
CheckDef
One custom check from [rules.checks.<id>].
CheckHit
A fired check on a node — the data a violation is built from.
CompiledCheck
A compiled check: its id, the parsed predicate program, its definition, and which graph collections the predicate references (so eval binds only those).
GraphView
A read-only view of the fully-built level, prepared once per check run and shared across every node’s predicate. Holds the dependency adjacency (by node id → neighbour labels) and the project’s file set / per-folder index. A node’s label is its repo-relative path attribute when present, else its id (so an external crate stays ext:<name>).

Functions§

compile
Compile one check’s when predicate. Named helpers from [rules.defs] are expanded into the predicate first (see [expand_defs]), so a check can reuse a shared vocabulary (is_domain, is_test_file, …).