@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-13/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-13 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Inner layer imports outer](../typescript/symptoms.md#inner-layer-imports-outer).
|
|
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-13/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: [Ports declared inside](../rules.md#ports-declared-inside).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Ports declared inside](../rules.md#ports-declared-inside) and [Port in the domain](../typescript/recipes.md#port-in-the-domain).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *The domain reaching for infrastructure.* Domain code imports an adapter or transport. Declare a port in the inner layer and implement it outside.
|
|
15
|
-
- *Layers not named.* Code is not sorted into layers, so direction cannot be seen. Name the layers and place each module.
|
|
16
|
-
- *Shared types living outside.* Inner code imports outer code only for a type. Move the type inward.
|
|
17
|
-
|
|
18
|
-
**Where to go.** The domain depends on nothing. The application orchestrates the domain. Adapters implement inner ports. Transports sit at the edge.
|
|
11
|
+
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).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "It's just one import." It is the direction that matters; one import is how it reverses.
|
|
13
|
+
## Spirit
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
- *The Dependency Rule* (Robert C. Martin, *Clean Architecture*). Source dependencies point only inward.
|
|
25
|
-
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). The core declares ports; the outside implements them.
|
|
15
|
+
Start from the symptom a finding names: [Inner layer imports outer](../typescript/symptoms.md#inner-layer-imports-outer). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).
|
package/rules/CD-14/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-14 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptoms: [Authored class or this](../typescript/symptoms.md#authored-class-or-this) and [Library class built in place](../typescript/symptoms.md#library-class-built-in-place).
|
|
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-14/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: no-class recipe; Outside dependencies stay at boundaries; state a case.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Closure factory](../typescript/recipes.md#closure-factory), [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries) and Keeps state or settings across calls ([cases](../cases.md#no-hidden-effects)).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *State that changes between calls.* The class holds counters, caches or buffers. Replace it with a factory that keeps them in private bindings and returns functions.
|
|
15
|
-
- *A namespace with a constructor.* The methods only read configuration, or the members are all static. Make them plain functions that take that configuration as an argument.
|
|
16
|
-
- *Inheritance used for reuse.* A base class shares behaviour. Compose functions instead.
|
|
17
|
-
- *A library class spreading.* A library's class is built in many places or handed out. Build it once inside its wrapping factory and expose functions.
|
|
18
|
-
|
|
19
|
-
**Where to go.** No authored classes. A library class is built only in its wrapping factory and never leaves it as a class.
|
|
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
|
-
- "Classes are just syntax." The concern is state hidden behind a shared reference and reuse by inheritance, not the keyword.
|
|
23
|
-
- "The library needs `new`." The rule allows that, inside the wrapping factory.
|
|
24
|
-
- "Errors need classes." Operational failures are plain data returned as results (CD-9, CD-11).
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Favour composition over inheritance* (Gamma, Helm, Johnson and Vlissides, *Design Patterns*). Behaviour assembled from parts changes more safely than behaviour inherited from a base.
|
|
28
|
-
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). A library's class belongs inside its adapter, behind your own functions.
|
|
15
|
+
Start from the symptom a finding names: [Authored class or this](../typescript/symptoms.md#authored-class-or-this) and [Library class built in place](../typescript/symptoms.md#library-class-built-in-place). 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) and [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).
|
package/rules/CD-15/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-15 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Loop keyword](../typescript/symptoms.md#loop-keyword).
|
|
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-15/README.md
CHANGED
|
@@ -2,29 +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 of [No hidden effects](../principles.md#no-hidden-effects).
|
|
8
|
+
|
|
9
|
+
**Read.** [No hidden effects](../principles.md#no-hidden-effects), Makes a new value from what it has ([cases](../cases.md#no-hidden-effects)) and [Functional iteration](../typescript/recipes.md#functional-iteration).
|
|
8
10
|
|
|
9
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).
|
|
10
12
|
|
|
11
13
|
## Spirit
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**What a finding points at.** Match the sites against these causes.
|
|
16
|
-
- *A transformation hidden in control flow.* The body builds one result from each element. Express it as a map, filter or reduce.
|
|
17
|
-
- *Several jobs in one pass.* One loop filters, reshapes and records. Split it into named steps.
|
|
18
|
-
- *Effects mixed with computation.* The loop computes and writes at once. Compute the result first, then perform the effects at the edge.
|
|
19
|
-
- *A stream being drained.* Consuming an async stream is a limit of the language, not debt. Record the site as an authorised location; it is fully compliant.
|
|
20
|
-
|
|
21
|
-
**Where to go.** Iteration reads as data flowing through named transformations, with effects at the end.
|
|
22
|
-
|
|
23
|
-
**Reactions to distrust.**
|
|
24
|
-
- "Loops are faster." Usually unmeasured, and the rule makes no performance carve-out. Measure before arguing it.
|
|
25
|
-
- "It's just tests." A loop in a test is several cases in one. Use one parameterised test over the rows (CD-27).
|
|
26
|
-
- "A loop is clearer here." Clearer to the writer, who knows what it builds. Name what it builds.
|
|
27
|
-
|
|
28
|
-
**Principles behind it.**
|
|
29
|
-
- *Replace Loop with Pipeline* (Martin Fowler, *Refactoring*, second edition). A collection pipeline names each step of the processing.
|
|
30
|
-
- *Functional core, imperative shell* (Gary Bernhardt). The transformation is pure; effects run at the edge on its result.
|
|
15
|
+
Start from the symptom a finding names: [Loop keyword](../typescript/symptoms.md#loop-keyword). 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-16/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-16 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Loop keyword](../typescript/symptoms.md#loop-keyword).
|
|
4
|
+
|
|
5
|
+
Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics.
|
|
4
6
|
|
|
5
7
|
## How it is checked
|
|
6
8
|
|
package/rules/CD-16/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
|
|
7
|
+
**Verdict.** Merges with CD-15.
|
|
8
|
+
|
|
9
|
+
**Read.** [No hidden effects](../principles.md#no-hidden-effects) and [Functional iteration](../typescript/recipes.md#functional-iteration).
|
|
10
10
|
|
|
11
11
|
Review lens: [function-first](../../methods/lenses/function-first.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).
|
|
12
12
|
|
|
13
13
|
## Spirit
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Start from the symptom a finding names: [Loop keyword](../typescript/symptoms.md#loop-keyword). 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-17/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-17 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Date used directly](../typescript/symptoms.md#date-used-directly).
|
|
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-17/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.** Cases under Handed what it uses and One reason per module.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Handed what it uses](../rules.md#handed-what-it-uses), [One reason per module](../rules.md#one-reason-per-module), Needs the current time, a random value, a new id or an outside ordering ([cases](../cases.md#external-behaviour-sits-at-a-boundary)) and [World values through a port](../typescript/recipes.md#world-values-through-a-port).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Decisions that read the clock.* Business logic asks for the current time in the middle of a calculation. Pass the instant in, or inject the clock.
|
|
15
|
-
- *Time stamped in many places.* Many sites stamp records or events. One clock port at the edge; the instant travels inward as data.
|
|
16
|
-
- *Tests that wait or depend on wall time.* Flaky or slow tests point at a missing clock port. Inject a stub clock that returns written-out instants.
|
|
17
|
-
- *Tests that build their own instants.* A test making dates for itself is choosing time outside the clock. Take instants from the stub clock.
|
|
18
|
-
|
|
19
|
-
**Where to go.** One clock abstraction reads real time. Everything else receives an instant or the clock. Tests set the time they need.
|
|
11
|
+
Review lens: [di-discipline](../../methods/lenses/di-discipline.md), [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).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "It's just a log timestamp." It is still output nobody can pin in a test. Read it through the clock.
|
|
23
|
-
- "It's just tests." The rule covers tests. A test that reads real time cannot be repeated exactly.
|
|
24
|
-
- "Exclude that folder." Then that folder's behaviour depends on the hour it runs. Find the clock port it is missing.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Dependency Inversion Principle* (Robert C. Martin, SOLID). Time is a detail; the logic depends on a clock abstraction it is given.
|
|
28
|
-
- *Functional core, imperative shell* (Gary Bernhardt). Reading the clock is an effect at the shell. The core receives the instant as a value and stays pure.
|
|
15
|
+
Start from the symptom a finding names: [Date used directly](../typescript/symptoms.md#date-used-directly). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary), [One place decides](../principles.md#one-place-decides) and [Tests are ours](../principles.md#tests-are-ours).
|
package/rules/CD-18/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-18 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Process global used in place](../typescript/symptoms.md#process-global-used-in-place).
|
|
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-18/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 under [Ports declared inside](../rules.md#ports-declared-inside).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Ports declared inside](../rules.md#ports-declared-inside) and [World values through a port](../typescript/recipes.md#world-values-through-a-port).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Exit called deep inside.* A function ends the process instead of returning. Return the outcome; let the entry point decide to exit.
|
|
15
|
-
- *Signal handling scattered.* Several modules register handlers. Gather lifecycle in one port wired at startup.
|
|
16
|
-
- *Timing read from the process.* Code measures time through the process global. Inject it.
|
|
17
|
-
|
|
18
|
-
**Where to go.** Lifecycle operations arrive through one injected port. Only the composition root touches the real process.
|
|
11
|
+
Review lens: [di-discipline](../../methods/lenses/di-discipline.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 a CLI, exit is normal." Exit at the entry point. Everywhere else, return.
|
|
13
|
+
## Spirit
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
- *Dependency Inversion Principle* (Robert C. Martin, SOLID). Code depends on a lifecycle abstraction, not the runtime global.
|
|
25
|
-
- *Functional core, imperative shell* (Gary Bernhardt). The decision to stop is a value; stopping happens at the shell.
|
|
15
|
+
Start from the symptom a finding names: [Process global used in place](../typescript/symptoms.md#process-global-used-in-place). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).
|
package/rules/CD-19/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-19 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Outside import past a boundary](../typescript/symptoms.md#outside-import-past-a-boundary).
|
|
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
|
|
|
@@ -15,7 +17,7 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: wha
|
|
|
15
17
|
- The source rule covers every third-party dependency; the check covers only the listed packages. The rest is left to review.
|
|
16
18
|
|
|
17
19
|
## Settings
|
|
18
|
-
List each
|
|
20
|
+
List each outside dependency the repository confines to its adapter in `disciplines.json`, then record each adapter file as an `authorised-location`:
|
|
19
21
|
|
|
20
22
|
```json
|
|
21
23
|
"clauseSettings": {
|
|
@@ -32,13 +34,13 @@ import { v4 } from "uuid";
|
|
|
32
34
|
|
|
33
35
|
## How to fix
|
|
34
36
|
```ts
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
+
import type { FileReader } from "./file-reader.ts";
|
|
38
|
+
import type { IdGenerator } from "./id-generator.ts";
|
|
37
39
|
```
|
|
38
|
-
Import your own port. Only the
|
|
40
|
+
Import your own port and take it in the unit's argument. Only the adapter for that outside party imports the library.
|
|
39
41
|
|
|
40
42
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the
|
|
43
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the adapter for that outside dependency. 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).
|
|
42
44
|
|
|
43
45
|
```json
|
|
44
46
|
{ "version": 1, "exceptions": [
|
package/rules/CD-19/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.** Splits: Outside dependencies stay at boundaries; Ports declared inside; construction and ids cases.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries), [Ports declared inside](../rules.md#ports-declared-inside), Builds the real implementations ([cases](../cases.md#one-place-decides)), Needs the current time, a random value, a new id or an outside ordering ([cases](../cases.md#external-behaviour-sits-at-a-boundary)), [World values through a port](../typescript/recipes.md#world-values-through-a-port) and [Adapter per outside party](../typescript/recipes.md#adapter-per-outside-party).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A capability with no name.* Many files import the same library or runtime module. Name the capability, wrap it once, inject it.
|
|
15
|
-
- *A port that leaks.* A wrapper exists but passes vendor types or objects through, so callers import the vendor anyway. Make the port speak your types.
|
|
16
|
-
- *Decisions doing I/O.* A runtime call sits in the middle of business logic. Separate the decision from the effect; the effect arrives through a port.
|
|
17
|
-
- *Construction spread everywhere.* Each module builds its own dependencies. Move construction to one composition root that passes ports in.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Each external capability has one wrapping file, recorded as its authorised location. Everything else imports your port. Opening a new wrapper is a recorded decision, not an inline one.
|
|
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
|
-
- "It's only the standard library." The same reasons apply: it cannot be replaced in a test and it ties logic to a platform. The rule makes no stdlib carve-out.
|
|
23
|
-
- "Wrapping is boilerplate." One small file per capability, against the whole codebase knowing a vendor's surface.
|
|
24
|
-
- "Exclude that folder." An excluded folder is a boundary nobody designed. Design it, then authorise the one file.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Dependency Inversion Principle* (Robert C. Martin, SOLID). Your code depends on an abstraction you own; the vendor detail depends on it, not the other way round.
|
|
28
|
-
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). The application talks through ports; one adapter per outside system translates. Swapping the system means swapping the adapter.
|
|
29
|
-
- *Functional core, imperative shell* (Gary Bernhardt). Decisions stay pure; effects live at the edge and arrive through ports.
|
|
15
|
+
Start from the symptom a finding names: [Outside import past a boundary](../typescript/symptoms.md#outside-import-past-a-boundary) and [Outside type in a signature](../typescript/symptoms.md#outside-type-in-a-signature). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).
|
package/rules/CD-2/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-2 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Claimed type](../typescript/symptoms.md#claimed-type).
|
|
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
|
|
|
@@ -36,9 +38,9 @@ const name = user.name!;
|
|
|
36
38
|
## How to fix
|
|
37
39
|
```ts
|
|
38
40
|
const user = userSchema.parse(response);
|
|
39
|
-
const name = user.name
|
|
41
|
+
const name = user.name;
|
|
40
42
|
```
|
|
41
|
-
Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check
|
|
43
|
+
Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check or an early return; for a binding assigned later, initialise it where it is declared or make it a `const` built from what it needs.
|
|
42
44
|
|
|
43
45
|
In a test file, `CD-27#test-body-logic` flags an `if` check at either edition, and its edition 2 flags the `??` fallback: there, `assert.isDefined` a value that may be missing before reading it, as [CD-27's allowed forms](../CD-27/CHECKS.md#a-short-circuit) show.
|
|
44
46
|
|
package/rules/CD-2/README.md
CHANGED
|
@@ -2,29 +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: [Declared, not asserted](../rules.md#declared-not-asserted).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Declared, not asserted](../rules.md#declared-not-asserted) and [Fix the declaration, not the value](../typescript/recipes.md#fix-the-declaration-not-the-value).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Parsing skipped at a boundary.* Raw input is asserted into shape instead of checked. Parse it once where it enters and the type follows.
|
|
15
|
-
- *A declared type that is wrong.* The code builds something its type does not describe. Fix the declaration and the cast goes.
|
|
16
|
-
- *A boundary that is missing.* Casts cluster around one library or data source across many files. Make one wrapping file the boundary and keep the rest cast-free.
|
|
17
|
-
- *A return type wider than its use.* A function returns a broad type and every caller narrows it. Return the narrow type.
|
|
18
|
-
- *A parameter type wider than its use.* A function asks for a whole record but reads two fields. It shows in tests, where someone casts a two-field object through to the full type rather than build it all. The function asks for more than it needs. Accept only the fields it uses; the test then builds those two fields honestly.
|
|
19
|
-
|
|
20
|
-
**Where to go.** Casts live only in a few named boundary files, each recorded as an authorised location. Clean boundaries make that cheap; that is what authorised locations are for. Everywhere else the type follows from a check.
|
|
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).
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
- "It's just tests." Tests are violations too. A test that casts is building a value its type does not allow. Either build it properly, or the unit asks for more than it uses.
|
|
24
|
-
- "Add a permission for this shape." Measure first. A permission can hide a real defect, such as database rows that were never parsed.
|
|
25
|
-
- "The library forces it." It forces one site. Put that site in the wrapping file.
|
|
13
|
+
## Spirit
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
- *Parse, don't validate* (Alexis King). A parse produces the type; a cast only claims it. Parse once at the boundary and the claim is never needed.
|
|
29
|
-
- *Interface Segregation Principle* (Robert C. Martin, SOLID). Depend only on what you use. A parameter that asks for exactly the fields it reads needs no cast to satisfy, in production or in tests.
|
|
30
|
-
- *Ports and adapters* (Alistair Cockburn, hexagonal architecture). The adapter at the edge is where outside shapes are translated, so it is the one place an unavoidable assertion belongs.
|
|
15
|
+
Start from the symptom a finding names: [Claimed type](../typescript/symptoms.md#claimed-type). 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-20/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-20 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Outside import past a boundary](../typescript/symptoms.md#outside-import-past-a-boundary).
|
|
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
|
## How it is checked
|
|
6
8
|
|
package/rules/CD-20/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
|
|
7
|
+
**Verdict.** Merges with CD-19.
|
|
8
|
+
|
|
9
|
+
**Read.** [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries), [Ports declared inside](../rules.md#ports-declared-inside) and [Adapter per outside party](../typescript/recipes.md#adapter-per-outside-party).
|
|
10
10
|
|
|
11
11
|
Review lens: [di-discipline](../../methods/lenses/di-discipline.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).
|
|
12
12
|
|
|
13
13
|
## Spirit
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Start from the symptom a finding names: [Outside import past a boundary](../typescript/symptoms.md#outside-import-past-a-boundary). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).
|
package/rules/CD-21/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-21 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Recipe: [Composition root](../typescript/recipes.md#composition-root). The outcome it protects is seen by [Adapter built outside the root](../typescript/symptoms.md#adapter-built-outside-the-root).
|
|
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-21/README.md
CHANGED
|
@@ -2,23 +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: built at the entry point.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** Builds the real implementations ([cases](../cases.md#one-place-decides)) and [Composition root](../typescript/recipes.md#composition-root).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Construction scattered.* Several places build the real implementation differently. Move it into a default factory beside the port.
|
|
15
|
-
- *A port invented only for tests.* It has test doubles but no real implementation. Either give it a default or question whether it is a port.
|
|
16
|
-
|
|
17
|
-
**Where to go.** Each port's module exports its default production factory. Production wires the default; tests pass test doubles.
|
|
11
|
+
Review lens: [di-discipline](../../methods/lenses/di-discipline.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).
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
- "The composition root builds it." It still calls one canonical factory, not its own construction.
|
|
13
|
+
## Spirit
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
- *Composition root.* All wiring happens in one place, from canonical factories.
|
|
24
|
-
- *Dependency Inversion Principle* (Robert C. Martin, SOLID). Callers depend on the port; the default is one implementation of it.
|
|
15
|
+
Start from the symptom a finding names: [Adapter built outside the root](../typescript/symptoms.md#adapter-built-outside-the-root). 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-22/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-22 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Recipe: [Bounded context generic](../typescript/recipes.md#bounded-context-generic). The outcome it protects is seen by [Default for a required value](../typescript/symptoms.md#default-for-a-required-value).
|
|
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-22/README.md
CHANGED
|
@@ -2,23 +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 [Declared, not asserted](../rules.md#declared-not-asserted).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Declared, not asserted](../rules.md#declared-not-asserted) and [Bounded context generic](../typescript/recipes.md#bounded-context-generic).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *Context read defensively.* Middleware checks or defaults a field like the clock or logger. Constrain its context type so the field must exist.
|
|
15
|
-
- *Layers that add capabilities untyped.* Earlier layers add fields the type never records. Widen the generic at each layer.
|
|
16
|
-
|
|
17
|
-
**Where to go.** Each middleware declares the context it needs through a constrained generic. A missing capability is a compile error.
|
|
11
|
+
Review lens: [di-discipline](../../methods/lenses/di-discipline.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).
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
- "A default is safer." A default hides wiring mistakes until they matter.
|
|
13
|
+
## Spirit
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
- *Make illegal states unrepresentable* (Yaron Minsky). A context type that requires the field cannot be built without it.
|
|
24
|
-
- *Explicit dependencies.* A unit states what it needs in its signature, not by reaching into a shared bag.
|
|
15
|
+
Start from the symptom a finding names: [Default for a required value](../typescript/symptoms.md#default-for-a-required-value). 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).
|