Skip to content

generated_file_fresh

A committed artefact must equal what a declared command generator produces, in one of two modes (exactly one of file / outputs). alint never leaves regenerated files behind — it verifies freshness, it does not run codegen as a build step. Either mode runs a user-declared, maintainer-trusted process, so the kind is trust-gated to your own top-level config (same tier as the command rule). Single-shot, opt-in. Spawn-failure / non-zero exit / timeout are each a clear, distinct violation. normalize (none / trim / final-newline) absorbs trailing-newline churn.

  • stdout mode (file:) — the generator writes its single output to stdout; alint captures it and compares to the one committed file. Never writes the tree.
  • mutating / in-place mode (outputs:, a glob or list) — for the common make gen && git diff --exit-code pattern, where the generator rewrites files in place. alint snapshots the outputs, runs the generator, diffs (flagging each stale / newly-created / removed file), and restores the snapshot — so alint check leaves the working tree byte-identical (the restore is panic-safe). The generator must confine its writes to outputs.
OptionTypeRequiredDefaultDescription
commandlist of stringyesGenerator argv (no shell). STDOUT mode: emit the file’s contents to stdout. MUTATING mode: write the outputs in place.
filestringnullSTDOUT mode: the committed generated file to verify against the generator’s stdout.
normalizeone of none | trim | final-newlineNormalization applied before comparison to absorb trailing-newline churn: none, trim, or final-newline.
outputsOutputsSpecMUTATING mode: the glob (or list of globs) the in-place generator rewrites; its presence selects the mutating mode. alint snapshots these, runs the generator, diffs, and restores them.
timeoutinteger (>= 1)nullGenerator timeout in seconds (default 120). On timeout the child is killed and one violation is emitted.
workdirstringnullGenerator cwd, relative to the lint root (default: lint root).

Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths. This table is generated from the JSON Schema; option types and defaults are authoritative.

The rule fires on this repository:

gen/list.txt
gen/list.txt
alpha
STALE
charlie

With this .alint.yml:

version: 1
rules:
- id: list-fresh
kind: generated_file_fresh
file: gen/list.txt
command: ["sh", "-c", "printf 'alpha\\nbravo\\ncharlie\\n'"]
normalize: none
level: error

alint check reports:

Terminal window
--- gen/list.txt ---------------------------------------------------------------
x error list-fresh
gen/list.txt: is stale - its committed contents differ from `sh -c
printf 'alpha\nbravo\ncharlie\n'` output (first differs at line 2)
Summary (1 violation):
x 1 error
0 passing * 1 failing

A committed generated file matching its generator

Section titled “A committed generated file matching its generator”

This repository is compliant:

gen/list.txt
gen/list.txt
alpha
bravo
charlie

With this .alint.yml:

version: 1
rules:
- id: list-fresh
kind: generated_file_fresh
file: gen/list.txt
command: ["sh", "-c", "printf 'alpha\\nbravo\\ncharlie\\n'"]
normalize: none
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.