redline policy
Evaluate the rules a checker can decide, with no model call.
Some rules need no judgement: a TODO has a ticket reference or it does not. policy checks those rules against the added lines of a diff, with no model, and fails on a BLOCKER. The gate runs it as the policy job on every pull request. Run it yourself to reproduce that job. It also says how many rules it could not decide; redline review covers those.
Where it runs: Inside the product repository, or anywhere you have a diff. The gate runs it in CI.
Synopsis
redline policy --diff-file <path> [--fail-on <severity>] [--json]Flags
| Flag | Default | What it does |
|---|---|---|
--diff-file <path> | required | The unified diff to evaluate. Only added lines are checked. |
--fail-on <severity> | BLOCKER | The lowest severity that fails the run: BLOCKER, HIGH or SUGGESTION. |
--json | off | ok, findings, the rules evaluated, and how many need a model, as JSON on stdout. |
--help prints the same list from the CLI you have installed.
Examples
Check your branch
$ git diff main...HEAD > change.diff $ pnpm redline policy --diff-file change.diff src/a.ts:2 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. Add the ticket id on the same line, or do the work now. 1 finding(s) from 53 deterministic rule(s) 443 of the 496 rule(s) in the catalogue cannot be decided without a model and were not checked here — run `redline review` for those
$ git diff main...HEAD > change.diff $ npx redlinegate policy --diff-file change.diff src/a.ts:2 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. Add the ticket id on the same line, or do the work now. 1 finding(s) from 53 deterministic rule(s) 443 of the 496 rule(s) in the catalogue cannot be decided without a model and were not checked here — run `redline review` for those
$ git diff main...HEAD > change.diff $ yarn redline policy --diff-file change.diff src/a.ts:2 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. Add the ticket id on the same line, or do the work now. 1 finding(s) from 53 deterministic rule(s) 443 of the 496 rule(s) in the catalogue cannot be decided without a model and were not checked here — run `redline review` for those
$ git diff main...HEAD > change.diff $ bun run redline policy --diff-file change.diff src/a.ts:2 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. Add the ticket id on the same line, or do the work now. 1 finding(s) from 53 deterministic rule(s) 443 of the 496 rule(s) in the catalogue cannot be decided without a model and were not checked here — run `redline review` for those
Fail on HIGH as well
$ pnpm redline policy --diff-file change.diff --fail-on HIGH
$ npx redlinegate policy --diff-file change.diff --fail-on HIGH
$ yarn redline policy --diff-file change.diff --fail-on HIGH
$ bun run redline policy --diff-file change.diff --fail-on HIGH
Exit codes
| Code | Meaning |
|---|---|
0 | No finding at or above --fail-on. The example above exits 0: one HIGH does not fail the BLOCKER default. |
1 | At least one finding at or above --fail-on. |
2 | No --diff-file, or an unknown severity. |
Related
- Deterministic rules
- The merge gate
- redline review
- All commands and the shared exit codes
- Source:
cli/policy/checks.ts