@hailstails/hone 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +8 -8
- package/CHANGELOG.md +14 -0
- package/MIGRATING.md +17 -0
- package/README.md +10 -10
- package/api/testing.js +2 -2
- package/chunks/{chunk-FEWCJU7H.js → chunk-2O46EB4E.js} +6 -0
- package/chunks/{chunk-6SM3HKWO.js → chunk-5U4VTFD5.js} +88 -51
- package/core/check/tool-command.js +379 -56
- package/core/mechanism-port/runner-result-types.d.ts +4 -0
- package/docs/adding-a-discipline-or-mechanism.md +2 -0
- package/docs/extending.md +1 -0
- package/docs/output-contract.md +17 -6
- package/mechanisms/audit/CD-27/test-body-logic.js +5 -2
- package/mechanisms/audit/runner/runner.js +5 -3
- package/mechanisms/eslint/runner/runner.js +7 -3
- package/methods/assessment-template.md +2 -2
- package/methods/lenses/clean-architecture.md +7 -8
- package/methods/lenses/defended-on-intent.md +2 -2
- package/methods/lenses/di-discipline.md +10 -13
- package/methods/lenses/function-first.md +16 -18
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +4 -2
- package/rules/CD-1/README.md +6 -19
- package/rules/CD-10/CHECKS.md +5 -3
- package/rules/CD-10/README.md +6 -18
- package/rules/CD-11/CHECKS.md +4 -2
- package/rules/CD-11/README.md +6 -16
- package/rules/CD-12/CHECKS.md +4 -2
- package/rules/CD-12/README.md +6 -16
- package/rules/CD-13/CHECKS.md +4 -2
- package/rules/CD-13/README.md +6 -16
- package/rules/CD-14/CHECKS.md +3 -1
- package/rules/CD-14/README.md +6 -19
- package/rules/CD-15/CHECKS.md +3 -1
- package/rules/CD-15/README.md +5 -20
- package/rules/CD-16/CHECKS.md +3 -1
- package/rules/CD-16/README.md +6 -6
- package/rules/CD-17/CHECKS.md +3 -1
- package/rules/CD-17/README.md +6 -19
- package/rules/CD-18/CHECKS.md +4 -2
- package/rules/CD-18/README.md +6 -16
- package/rules/CD-19/CHECKS.md +8 -6
- package/rules/CD-19/README.md +6 -20
- package/rules/CD-2/CHECKS.md +5 -3
- package/rules/CD-2/README.md +6 -21
- package/rules/CD-20/CHECKS.md +3 -1
- package/rules/CD-20/README.md +6 -6
- package/rules/CD-21/CHECKS.md +4 -2
- package/rules/CD-21/README.md +6 -15
- package/rules/CD-22/CHECKS.md +4 -2
- package/rules/CD-22/README.md +6 -15
- package/rules/CD-23/CHECKS.md +5 -3
- package/rules/CD-23/README.md +6 -17
- package/rules/CD-24/CHECKS.md +3 -1
- package/rules/CD-24/README.md +6 -6
- package/rules/CD-25/CHECKS.md +3 -1
- package/rules/CD-25/README.md +5 -21
- package/rules/CD-26/CHECKS.md +5 -3
- package/rules/CD-26/README.md +6 -20
- package/rules/CD-27/CHECKS.md +16 -7
- package/rules/CD-27/README.md +6 -20
- package/rules/CD-28/CHECKS.md +4 -2
- package/rules/CD-28/README.md +6 -16
- package/rules/CD-29/CHECKS.md +4 -2
- package/rules/CD-29/README.md +6 -14
- package/rules/CD-3/CHECKS.md +3 -1
- package/rules/CD-3/README.md +6 -17
- package/rules/CD-30/CHECKS.md +4 -2
- package/rules/CD-30/README.md +6 -15
- package/rules/CD-31/CHECKS.md +4 -2
- package/rules/CD-31/README.md +6 -14
- package/rules/CD-32/CHECKS.md +3 -1
- package/rules/CD-32/README.md +2 -0
- package/rules/CD-33/CHECKS.md +3 -1
- package/rules/CD-33/README.md +2 -0
- package/rules/CD-34/CHECKS.md +3 -1
- package/rules/CD-34/README.md +2 -0
- package/rules/CD-39/CHECKS.md +3 -1
- package/rules/CD-39/README.md +2 -0
- package/rules/CD-4/CHECKS.md +4 -2
- package/rules/CD-4/README.md +6 -17
- package/rules/CD-40/CHECKS.md +3 -1
- package/rules/CD-40/README.md +6 -20
- package/rules/CD-41/CHECKS.md +4 -2
- package/rules/CD-41/README.md +6 -22
- package/rules/CD-42/CHECKS.md +3 -1
- package/rules/CD-42/README.md +6 -16
- package/rules/CD-43/CHECKS.md +3 -1
- package/rules/CD-43/README.md +6 -18
- package/rules/CD-44/CHECKS.md +3 -1
- package/rules/CD-44/README.md +6 -17
- package/rules/CD-45/CHECKS.md +4 -2
- package/rules/CD-45/README.md +6 -16
- package/rules/CD-46/CHECKS.md +3 -1
- package/rules/CD-46/README.md +2 -0
- package/rules/CD-47/CHECKS.md +4 -2
- package/rules/CD-47/README.md +4 -20
- package/rules/CD-5/CHECKS.md +4 -2
- package/rules/CD-5/README.md +6 -19
- package/rules/CD-6/CHECKS.md +3 -1
- package/rules/CD-6/README.md +6 -19
- package/rules/CD-7/CHECKS.md +3 -1
- package/rules/CD-7/README.md +6 -20
- package/rules/CD-7a/CHECKS.md +3 -1
- package/rules/CD-7a/README.md +6 -17
- package/rules/CD-8/CHECKS.md +3 -1
- package/rules/CD-8/README.md +6 -17
- package/rules/CD-9/CHECKS.md +4 -2
- package/rules/CD-9/README.md +6 -17
- package/rules/README.md +71 -54
- package/rules/SPIRIT.md +3 -3
- package/rules/cases.md +94 -0
- package/rules/numbers.md +155 -0
- package/rules/principles.md +89 -0
- package/rules/records.md +150 -0
- package/rules/rules.md +149 -0
- package/rules/sources.md +142 -0
- package/rules/typescript/checks.md +219 -0
- package/rules/typescript/recipes.md +361 -0
- package/rules/typescript/symptoms.json +1005 -0
- package/rules/typescript/symptoms.md +612 -0
package/rules/CD-33/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-33 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Outside the cases: no symptom. [Every CD](../numbers.md) says where each number went.
|
|
4
|
+
|
|
5
|
+
Read [the rule and its spirit](README.md) first; the [named pages](../README.md) govern where they differ. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-33/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) says where each number went.
|
|
6
|
+
|
|
5
7
|
A value whose type is branded sensitive redacts unconditionally wherever it surfaces — logs, errors, serialisation — with no opt-out. Branding sensitivity into the type means the redaction travels with the value by construction, rather than depending on every call site remembering to hide it.
|
|
6
8
|
|
|
7
9
|
Review lens: [clean-architecture](../../methods/lenses/clean-architecture.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
package/rules/CD-34/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-34 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Outside the cases: no symptom. [Every CD](../numbers.md) says where each number went.
|
|
4
|
+
|
|
5
|
+
Read [the rule and its spirit](README.md) first; the [named pages](../README.md) govern where they differ. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-34/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) says where each number went.
|
|
6
|
+
|
|
5
7
|
Secrets live only in the environment or a secrets manager — never in source, never in logs, never in URL query parameters. A committed secret is compromised the moment it lands in history, whatever happens to it later; the repository is not a place a secret can safely exist.
|
|
6
8
|
|
|
7
9
|
Review lens: [clean-architecture](../../methods/lenses/clean-architecture.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
package/rules/CD-39/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-39 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Outside the cases: no symptom. [Every CD](../numbers.md) says where each number went.
|
|
4
|
+
|
|
5
|
+
Read [the rule and its spirit](README.md) first; the [named pages](../README.md) govern where they differ. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-39/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ. Rules are referred to by name; a clause address is still how a check is cited today, as [Every CD](../numbers.md) says.
|
|
6
|
+
|
|
5
7
|
Reviews and rationale cite specific rules by their identifier, not vague appeals to "the standards". A citation anchors a finding to the named rule and its intent, so remediation is precise and the disagreement, if any, is about the rule rather than about taste.
|
|
6
8
|
|
|
7
9
|
Review lens: none. A reviewer applies the rule text directly. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
package/rules/CD-4/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-4 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Recipe: [Zod at the producer's adapter](../typescript/recipes.md#zod-at-the-producers-adapter). The outcome it protects is seen by [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
10
12
|
|
|
11
13
|
## How it is checked
|
|
12
14
|
|
|
13
|
-
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the
|
|
15
|
+
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the named rules](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
|
package/rules/CD-4/README.md
CHANGED
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Recipe for the No leak case: [Zod at the producer's adapter](../typescript/recipes.md#zod-at-the-producers-adapter).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Zod at the producer's adapter](../typescript/recipes.md#zod-at-the-producers-adapter) and Reads data from outside ([cases](../cases.md#no-leak-across-a-boundary)).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Input trusted on arrival.* A request, file, environment value, or database row is used as if typed. Parse it with a schema at the seam.
|
|
15
|
-
- *No clear seam.* Outside data enters in many places. Gather each source behind one adapter that parses it.
|
|
16
|
-
- *Checks scattered inward.* Inner code tests fields for presence. That means nothing parsed at the edge; move the check there.
|
|
17
|
-
|
|
18
|
-
**Where to go.** Every outside source has one seam that parses it into plain typed data. Nothing inside checks shape again.
|
|
11
|
+
Review lens: [zod-boundary](../../methods/lenses/zod-boundary.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "It's our own database." It is still outside the type system. Rows can be anything the schema has ever allowed.
|
|
22
|
-
- "The client already validates." The server cannot rely on code it does not run.
|
|
13
|
+
## Spirit
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
- *Parse, don't validate* (Alexis King). Parsing produces a typed value once; validation leaves the raw value to be checked again.
|
|
26
|
-
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). Each outside system enters through one adapter, which is where its data is translated.
|
|
15
|
+
Start from the symptom a finding names: [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter). Each symptom names the cases it may indicate and the rules they point at. The why is on [No leak across a boundary](../principles.md#no-leak-across-a-boundary).
|
package/rules/CD-40/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-40 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Positional parameters](../typescript/symptoms.md#positional-parameters).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-40/README.md
CHANGED
|
@@ -2,28 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Cases of One word everywhere, Handed what it uses.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [One word everywhere](../rules.md#one-word-everywhere), [Handed what it uses](../rules.md#handed-what-it-uses) and [One argument object](../typescript/recipes.md#one-argument-object).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Values that travel together without a name.* The same group of arguments passes through several functions. Name the group as one type.
|
|
15
|
-
- *A function with several jobs.* It has many parameters because it serves many concerns. Split it.
|
|
16
|
-
- *Flags steering behaviour.* An argument switches between modes. Split the function, or make the mode a named union.
|
|
17
|
-
- *Asking for more than it uses.* Converting to one object invites passing a whole record. Take only the fields the function reads; tests then build only those.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Every function takes one object whose fields are named and minimal. Adding a field breaks no caller.
|
|
11
|
+
Review lens: [function-first](../../methods/lenses/function-first.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "Two parameters is fine." The rule asks for one named object. Two positional values already have an order to get wrong.
|
|
23
|
-
- "The library dictates this callback." Then the callback is the boundary. Hand off to a single-object function on its first line.
|
|
24
|
-
- "An object is more typing." It is a few characters at the call site, against every reader guessing the order.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Function arguments* (Robert C. Martin, *Clean Code*). Each extra argument is something the reader must hold in mind and the caller can get wrong.
|
|
28
|
-
- *Introduce Parameter Object* (Martin Fowler, *Refactoring*). The refactoring that names a group of values that travel together.
|
|
29
|
-
- *Interface Segregation Principle* (Robert C. Martin, SOLID). The object asks for exactly the fields used, no more.
|
|
15
|
+
Start from the symptom a finding names: [Positional parameters](../typescript/symptoms.md#positional-parameters). Each symptom names the cases it may indicate and the rules they point at. The why is on [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language) and [One place decides](../principles.md#one-place-decides).
|
package/rules/CD-41/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-41 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptoms: [Long function](../typescript/symptoms.md#long-function), [Tangled function](../typescript/symptoms.md#tangled-function) and [Orchestrator that computes](../typescript/symptoms.md#orchestrator-that-computes).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -50,7 +52,7 @@ const settle = (orders: Order[]) => {
|
|
|
50
52
|
```ts
|
|
51
53
|
const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
|
|
52
54
|
```
|
|
53
|
-
Move
|
|
55
|
+
Move any computing or branching between calls into a named doer, so the orchestrator only composes calls.
|
|
54
56
|
|
|
55
57
|
## Exceptions
|
|
56
58
|
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file holds a function whose shape is fixed by an external contract. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. Judgement clauses cannot be selected and need no exception record. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
package/rules/CD-41/README.md
CHANGED
|
@@ -2,30 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
10
|
-
|
|
11
|
-
**What the friction is for.** A function that coordinates and computes at once has to be read at two levels of detail at once. The friction makes small named steps the easy shape, so each level reads as one idea.
|
|
7
|
+
**Verdict.** Keeps: [Doer or orchestrator](../rules.md#doer-or-orchestrator).
|
|
12
8
|
|
|
13
|
-
**
|
|
14
|
-
- *Logic that never got a name.* A block of branching or computation sits inside a coordinator. Extract it into a named helper; the name says what it decides.
|
|
15
|
-
- *One function with several jobs.* It validates, decides and performs, so it grows long and tangled. Split it by job.
|
|
16
|
-
- *Failures checked inline.* Nesting deepens because each failure is handled in place. Return early on failure, or let helpers return results the coordinator only routes.
|
|
17
|
-
- *Shapes that do not meet.* The coordinator reshapes data between calls because its helpers disagree. Align the helpers' inputs and outputs.
|
|
9
|
+
**Read.** [Doer or orchestrator](../rules.md#doer-or-orchestrator) and [Composed orchestrator](../typescript/recipes.md#composed-orchestrator).
|
|
18
10
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
**Where to go.** Coordinators read as a short list of named steps. Each helper does one thing at one level of detail.
|
|
11
|
+
Review lens: [decomposition](../../methods/lenses/decomposition.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
- "It's only a little logic." A little logic in a coordinator is still a second level of detail to read. Give it a name.
|
|
25
|
-
- "Splitting makes it harder to follow." Named steps read faster than inline logic once the names are honest.
|
|
26
|
-
- "This branch is just plumbing." If it decides anything, it is logic. Name what it decides.
|
|
13
|
+
## Spirit
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
- *Composed Method* (Kent Beck, *Smalltalk Best Practice Patterns*). A method is a sequence of calls to other methods, all at the same level of abstraction.
|
|
30
|
-
- *One level of abstraction per function* (Robert C. Martin, *Clean Code*). Mixing coordination with detail forces the reader to switch levels mid-function.
|
|
31
|
-
- *Functions should do one thing* (Robert C. Martin, *Clean Code*). A coordinator's one thing is coordinating; computing is a second thing.
|
|
15
|
+
Start from the symptom a finding names: [Long function](../typescript/symptoms.md#long-function), [Tangled function](../typescript/symptoms.md#tangled-function) and [Orchestrator that computes](../typescript/symptoms.md#orchestrator-that-computes). Each symptom names the cases it may indicate and the rules they point at. The why is on [One place decides](../principles.md#one-place-decides).
|
package/rules/CD-42/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-42 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Work inside a condition](../typescript/symptoms.md#work-inside-a-condition).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-42/README.md
CHANGED
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Keeps: [Guard first](../rules.md#guard-first).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Guard first](../rules.md#guard-first) and [Guard clauses](../typescript/recipes.md#guard-clauses).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Failures handled after success.* The happy path sits inside an if and the failure in the else. Invert it: return early on failure.
|
|
15
|
-
- *Several checks nested inside each other.* Each guard adds a level. Make each a separate early return.
|
|
16
|
-
- *A function with two jobs.* Both branches do real work. Split it into two functions.
|
|
17
|
-
|
|
18
|
-
**Where to go.** Guards at the top, each returning early. The final return is the happy path, with no else.
|
|
11
|
+
Review lens: [decomposition](../../methods/lenses/decomposition.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "Single exit is cleaner." It forces nesting and a variable to carry the answer. Early returns keep each case in one place.
|
|
22
|
-
- "The else makes it explicit." After a return, the else adds only indentation.
|
|
13
|
+
## Spirit
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
- *Replace Nested Conditional with Guard Clauses* (Martin Fowler, *Refactoring*). Unusual cases leave early; the normal case reads straight down.
|
|
15
|
+
Start from the symptom a finding names: [Work inside a condition](../typescript/symptoms.md#work-inside-a-condition). Each symptom names the cases it may indicate and the rules they point at. The why is on [One place decides](../principles.md#one-place-decides).
|
package/rules/CD-43/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-43 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Boolean in a signature](../typescript/symptoms.md#boolean-in-a-signature).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-43/README.md
CHANGED
|
@@ -2,26 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Keeps: [Kinds are named](../rules.md#kinds-are-named).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Kinds are named](../rules.md#kinds-are-named) and [Tagged union and exhaustive switch](../typescript/recipes.md#tagged-union-and-exhaustive-switch).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A mode passed as a flag.* A parameter switches the function between behaviours. Split the function, or name the modes as a union.
|
|
15
|
-
- *A state that will grow.* Today it is on or off; tomorrow there is a third case and a second flag. Name the states now.
|
|
16
|
-
- *Two flags that cannot both be true.* Pairs of booleans allow combinations that make no sense. One union rules them out.
|
|
17
|
-
- *An outcome as a boolean.* A result says success or not, and the reason is lost. Return a tagged outcome.
|
|
18
|
-
|
|
19
|
-
**Where to go.** States and modes are named values. A reader learns the meaning from the value itself.
|
|
11
|
+
Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "It's obviously a yes or no." Then name what yes means. If that is easy, the union is easy.
|
|
23
|
-
- "The library returns a boolean." Read it at the boundary and turn it into your own named state there.
|
|
13
|
+
## Spirit
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
- *Make illegal states unrepresentable* (Yaron Minsky). A union of named states rules out the combinations flags allow.
|
|
27
|
-
- *Flag arguments* (Robert C. Martin, *Clean Code*). A boolean argument announces that the function does more than one thing.
|
|
15
|
+
Start from the symptom a finding names: [Boolean in a signature](../typescript/symptoms.md#boolean-in-a-signature). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
|
package/rules/CD-44/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-44 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptoms: [Write into a parameter](../typescript/symptoms.md#write-into-a-parameter) and [Rebinding](../typescript/symptoms.md#rebinding).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
package/rules/CD-44/README.md
CHANGED
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Cases of [No hidden effects](../principles.md#no-hidden-effects).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [No hidden effects](../principles.md#no-hidden-effects) and [Copy, never write in](../typescript/recipes.md#copy-never-write-in).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A function that both answers and changes.* It returns something and also edits what it was given. Return the new value; leave the input alone.
|
|
15
|
-
- *Ownership nobody decided.* Several functions edit one shared object in turn. Decide who builds the value, and pass results forward instead.
|
|
16
|
-
- *In-place sorting or pushing for convenience.* A library call mutates by default. Use the copying form, or copy first.
|
|
17
|
-
- *Accumulators passed in.* A collection is handed in to be filled. Return the items and let the caller combine them.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Inputs are read-only. Functions return new values, and the caller decides what to keep.
|
|
11
|
+
Review lens: [decomposition](../../methods/lenses/decomposition.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "Copying is slow." Usually unmeasured, and the rule makes no performance carve-out.
|
|
23
|
-
- "The caller wants the change." Then return it, and the caller can see it.
|
|
13
|
+
## Spirit
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
- *Functional core, imperative shell* (Gary Bernhardt). The core takes values and returns values; changes happen at the edge.
|
|
15
|
+
Start from the symptom a finding names: [Write into a parameter](../typescript/symptoms.md#write-into-a-parameter) and [Rebinding](../typescript/symptoms.md#rebinding). Each symptom names the cases it may indicate and the rules they point at. The why is on [No hidden effects](../principles.md#no-hidden-effects).
|
package/rules/CD-45/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-45 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
10
12
|
|
|
11
13
|
## How it is checked
|
|
12
14
|
|
|
13
|
-
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the
|
|
15
|
+
Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the named rules](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
|
package/rules/CD-45/README.md
CHANGED
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Cases of [No leak across a boundary](../principles.md#no-leak-across-a-boundary).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [No leak across a boundary](../principles.md#no-leak-across-a-boundary), Reads data from outside ([cases](../cases.md#no-leak-across-a-boundary)) and [Zod at the producer's adapter](../typescript/recipes.md#zod-at-the-producers-adapter).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A boundary that does not finish its job.* The seam parses but passes the raw or validator-typed value on. Map it to a plain domain shape there.
|
|
15
|
-
- *Inner code that does not trust its inputs.* Inner functions parse again. Give them the parsed type so the check is unnecessary.
|
|
16
|
-
- *Validator types used as domain types.* The validation library's types appear in inner signatures. Declare your own types; the boundary maps to them.
|
|
17
|
-
|
|
18
|
-
**Where to go.** One parse per crossing, at the seam. Inner layers depend on your own types, never on the validator.
|
|
11
|
+
Review lens: [zod-boundary](../../methods/lenses/zod-boundary.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "Parsing again is safer." It is a sign the types inside cannot be trusted. Fix that instead.
|
|
13
|
+
## Spirit
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
- *Parse, don't validate* (Alexis King). After one parse the type carries the proof; checking again adds nothing.
|
|
25
|
-
- *Dependency Inversion Principle* (Robert C. Martin, SOLID). Inner layers depend on their own types, not on a library's.
|
|
15
|
+
Start from the symptom a finding names: [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter). Each symptom names the cases it may indicate and the rules they point at. The why is on [No leak across a boundary](../principles.md#no-leak-across-a-boundary).
|
package/rules/CD-46/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-46 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Record kind: [Debt](../records.md#debt).
|
|
4
|
+
|
|
5
|
+
Read [the rule and its spirit](README.md) first; the [named pages](../README.md) govern where they differ. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## How it is checked
|
|
6
8
|
|
package/rules/CD-46/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ: only [debt](../records.md#debt) is forfeited on touch.
|
|
6
|
+
|
|
5
7
|
A suppression or exemption is inherited debt held at rest, not a standing licence: it buys "leave this file alone", nothing more. The moment a change edits an exempt file, that file forfeits its exemption — the change must bring the whole file into compliance for the exempted rule (the new lines and the pre-existing ones the exemption was masking) and remove the exemption entry, in the same change. There is no partial credit and no extracting the touched code into a clean helper while the exempt file stays dirty. If full compliance is out of scope, the move is to not touch the file. This rule governs how every other exemption decays and can never itself be exempted.
|
|
6
8
|
|
|
7
9
|
Review lens: none. A reviewer applies the rule text directly. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
package/rules/CD-47/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-47 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Inherited environment in a subprocess](../typescript/symptoms.md#inherited-environment-in-a-subprocess).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -11,7 +13,7 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
|
|
|
11
13
|
## What the check flags
|
|
12
14
|
- Test files: `*.test.ts`, `*.test.tsx`, `*.test.mjs`, `*.test.js`, `*.spec.ts`, `*.spec.mjs`. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder can be left out with `exclude` in disciplines.json.
|
|
13
15
|
- A line calling `spawnSync`, `spawn`, `execFileSync`, `execFile`, `execSync`, `exec`, `execa` or `execaSync` with `"git"` (or `'git'`, or a template literal) as the first argument.
|
|
14
|
-
- Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The
|
|
16
|
+
- Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The environment comes from a unit of ours with its own test, not a test helper.
|
|
15
17
|
- Not detected: a command string such as `execSync("git status")`, a split call, or a non-literal command. Whether the spawn is warranted at all is left to review.
|
|
16
18
|
|
|
17
19
|
## Example violation
|
package/rules/CD-47/README.md
CHANGED
|
@@ -2,30 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Verdict.** Cases under [Tested where it's owned](../rules.md#tested-where-its-owned).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**Read.** [Tested where it's owned](../rules.md#tested-where-its-owned) and [Integration test owns its scratch](../typescript/recipes.md#integration-test-owns-its-scratch).
|
|
10
10
|
|
|
11
11
|
Review lens: [test-discipline](../../methods/lenses/test-discipline.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
12
12
|
|
|
13
13
|
## Spirit
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
**What a finding points at.** Match the sites against these causes.
|
|
18
|
-
- *A subsystem reached directly.* The code under test calls the real process, network, or filesystem. Inject a port and pass a test double.
|
|
19
|
-
- *Environment inherited by accident.* A spawned process picks up the developer's settings. Pass an explicit, created environment, or replace the process with a test double.
|
|
20
|
-
- *Setup that borrows the machine.* The test uses shared paths, home configuration, or the system clock. Create what it needs and remove it afterwards, or use a test double.
|
|
21
|
-
- *A real call used for convenience.* Realism or setup speed is the reason. Those never qualify; use a test double.
|
|
22
|
-
|
|
23
|
-
**Where to go.** Tests replace every real subsystem with a test double. The rare test whose subject is a subsystem's own behaviour brings its own instance and removes it.
|
|
24
|
-
|
|
25
|
-
**Reactions to distrust.**
|
|
26
|
-
- "It works on my machine." That is the problem: it depends on your machine.
|
|
27
|
-
- "A test double is more work." Once per subsystem, against every developer's environment being at risk.
|
|
28
|
-
|
|
29
|
-
**Principles behind it.**
|
|
30
|
-
- *Hermetic tests.* A test depends only on what it creates, so its result is the same on every machine.
|
|
31
|
-
- *Erratic Test* (a test smell in Gerard Meszaros, *xUnit Test Patterns*). Tests that share or leak real resources pass or fail by circumstance.
|
|
15
|
+
Start from the symptom a finding names: [Inherited environment in a subprocess](../typescript/symptoms.md#inherited-environment-in-a-subprocess) and [Machine touched in a unit test](../typescript/symptoms.md#machine-touched-in-a-unit-test). Each symptom names the cases it may indicate and the rules they point at. The why is on [Tests are ours](../principles.md#tests-are-ours).
|
package/rules/CD-5/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-5 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Untracked escape](../typescript/symptoms.md#untracked-escape).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|
|
@@ -38,7 +40,7 @@ const first = items[0]!;
|
|
|
38
40
|
```ts
|
|
39
41
|
const first = items[0];
|
|
40
42
|
```
|
|
41
|
-
Remove the need for the directive. If it must stay, add a tracked reference to the work that removes it: `// biome-ignore lint/style/noNonNullAssertion: until items is typed as
|
|
43
|
+
Remove the need for the directive. If it must stay, add a tracked reference to the work that removes it: `// biome-ignore lint/style/noNonNullAssertion: until items is typed as non-empty (#42)`. The reference satisfies this clause only. A directive that escapes a selected clause, such as an `eslint-disable` naming a selected rule or a `@ts-expect-error` under `CD-2#cast-expressions`, still needs a file record on that clause, and that record does not satisfy this clause.
|
|
42
44
|
|
|
43
45
|
## Exceptions
|
|
44
46
|
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file legitimately carries untracked directives, such as generated code. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
package/rules/CD-5/README.md
CHANGED
|
@@ -2,27 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Spirit
|
|
7
|
+
**Verdict.** Splits: One word everywhere; Declared, not asserted; records.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [One word everywhere](../rules.md#one-word-everywhere), [Declared, not asserted](../rules.md#declared-not-asserted), [Meaning in names, not comments](../typescript/recipes.md#meaning-in-names-not-comments) and [records](../records.md).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A name that says too little.* The comment explains what the name should. Rename, or extract a named function.
|
|
15
|
-
- *A rule the types do not hold.* The comment states an invariant. Move it into a type, a union or a schema, where it is checked.
|
|
16
|
-
- *A suppression standing in for a fix.* The directive silences another rule. That rule's finding is the real one; read its Spirit section.
|
|
17
|
-
- *A promise nobody holds.* An untracked TODO. Track it or do it.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Names, types and schemas carry the meaning, with no prose beside them. Each directive that remains carries a tracked reference to the work that retires it, so the count of directives falls over time rather than settling.
|
|
11
|
+
Review lens: [naming](../../methods/lenses/naming.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "This needs explaining." Then the code is not yet clear. The explanation is the brief for a better name.
|
|
23
|
-
- "Add a tracked reference and move on." A reference that excuses the escape instead of retiring it is the same hole with a label.
|
|
24
|
-
- "It's generated." Then that file is a boundary. Authorise it, and keep hand-written code clean.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Intention-revealing names* (Robert C. Martin, *Clean Code*). Clean Code treats a comment as compensating for code that failed to express its intent; the fix is in the code.
|
|
28
|
-
- *Make illegal states unrepresentable* (Yaron Minsky). An invariant stated in a type is checked on every change; the same invariant in a comment is checked by nobody.
|
|
15
|
+
Start from the symptom a finding names: [Untracked escape](../typescript/symptoms.md#untracked-escape) and [Prose in code](../typescript/symptoms.md#prose-in-code). Each symptom names the cases it may indicate and the rules they point at. The why is on [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language).
|
package/rules/CD-6/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-6 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptoms: [Shorthand name](../typescript/symptoms.md#shorthand-name) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
|
|
4
6
|
|
|
5
7
|
## Clauses
|
|
6
8
|
|