@hailstails/hone 1.3.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 +36 -0
- package/MIGRATING.md +40 -0
- package/README.md +28 -7
- package/api/audit.d.ts +1 -1
- package/api/testing.js +3 -3
- package/chunks/{chunk-H4V72FCW.js → chunk-2O46EB4E.js} +15 -1
- package/chunks/chunk-335ITLPO.js +7 -0
- package/chunks/{chunk-YSN46EB3.js → chunk-5U4VTFD5.js} +347 -664
- package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
- package/chunks/chunk-WF3PPYRR.js +27 -0
- package/core/check/tool-command.js +1120 -105
- package/core/mechanism-port/runner-result-types.d.ts +10 -0
- package/docs/adding-a-discipline-or-mechanism.md +5 -3
- package/docs/extending.md +2 -0
- package/docs/output-contract.md +64 -11
- package/mechanisms/audit/CD-27/test-body-logic.js +397 -46
- package/mechanisms/audit/runner/runner.js +5 -3
- package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
- package/mechanisms/eslint/CD-41/README.md +1 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
- package/mechanisms/eslint/runner/README.md +9 -2
- package/mechanisms/eslint/runner/runner.js +1410 -1384
- 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 +14 -18
- package/methods/lenses/function-first.md +16 -18
- package/methods/lenses/test-discipline.md +1 -1
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +6 -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 +5 -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 +7 -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 +5 -3
- 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 +394 -9
- package/rules/CD-27/README.md +6 -20
- package/rules/CD-27/discipline.json +130 -0
- 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 +14 -2
- package/rules/CD-41/README.md +6 -20
- package/rules/CD-41/discipline.json +14 -0
- 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/chunks/chunk-YLZ73C7O.js +0 -0
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
|
|
|
@@ -19,6 +21,16 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: wha
|
|
|
19
21
|
- A nested function is scored on its own, starting one level deeper, and its score is not added to its parent.
|
|
20
22
|
- Reported at the function's name.
|
|
21
23
|
- `hone-cd41/function-length`: a function body may span at most 50 lines. Blank and comment lines count; lines holding only `{` or `}` do not. Getters and setters are not checked. Reported at the function.
|
|
24
|
+
- A test suite's body is not checked. A suite body is a function passed as an argument to the call that runs a suite:
|
|
25
|
+
- `describe`, `suite`, `fdescribe`, `xdescribe`, `fsuite` or `xsuite`, alone or followed only by the modifiers `each`, `for`, `only`, `skip`, `todo`, `concurrent`, `sequential`, `shuffle`, `skipIf` and `runIf`, such as `describe.each(table)(name, fn)`, `describe.each` with a template table, `describe.only.each(table)(name, fn)` or `describe.skipIf(condition)(name, fn)`;
|
|
26
|
+
- Playwright's `test.describe`, alone or followed only by `only`, `skip`, `fixme`, `serial` and `parallel`, such as `test.describe.serial.only(name, fn)`.
|
|
27
|
+
- A suite nested in a suite is not checked either.
|
|
28
|
+
- Everything else is checked as any function is:
|
|
29
|
+
- each function inside a suite's body: each `it` and `test` callback, each hook and each helper declared there;
|
|
30
|
+
- a function given to `describe.each` as a table entry;
|
|
31
|
+
- a callback on any other member of those names, such as `test.describe.configure(fn)` or `suite.add(name, fn)` on a benchmark suite;
|
|
32
|
+
- mocha's `context`, and any other suite function not listed above.
|
|
33
|
+
- The check matches names, not bindings, so a local function of the repository's own named `describe` or `suite` is treated as a suite when called that way.
|
|
22
34
|
- `orchestration-only` is a judgement clause. It cannot be selected and is enforced by review.
|
|
23
35
|
|
|
24
36
|
## Example violation
|
|
@@ -40,7 +52,7 @@ const settle = (orders: Order[]) => {
|
|
|
40
52
|
```ts
|
|
41
53
|
const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
|
|
42
54
|
```
|
|
43
|
-
Move
|
|
55
|
+
Move any computing or branching between calls into a named doer, so the orchestrator only composes calls.
|
|
44
56
|
|
|
45
57
|
## Exceptions
|
|
46
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,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.** Keeps: [Doer or orchestrator](../rules.md#doer-or-orchestrator).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Doer or orchestrator](../rules.md#doer-or-orchestrator) and [Composed orchestrator](../typescript/recipes.md#composed-orchestrator).
|
|
12
10
|
|
|
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.
|
|
18
|
-
|
|
19
|
-
**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).
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
- "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.
|
|
23
|
-
- "Splitting makes it harder to follow." Named steps read faster than inline logic once the names are honest.
|
|
24
|
-
- "This branch is just plumbing." If it decides anything, it is logic. Name what it decides.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *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.
|
|
28
|
-
- *One level of abstraction per function* (Robert C. Martin, *Clean Code*). Mixing coordination with detail forces the reader to switch levels mid-function.
|
|
29
|
-
- *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).
|
|
@@ -96,6 +96,14 @@
|
|
|
96
96
|
"expectedLines": [
|
|
97
97
|
1
|
|
98
98
|
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "an it callback inside a describe",
|
|
102
|
+
"fileName": "src/steps.test.ts",
|
|
103
|
+
"source": "describe(\"steps\", () => {\n it(\"runs\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n });\n});\n",
|
|
104
|
+
"expectedLines": [
|
|
105
|
+
2
|
|
106
|
+
]
|
|
99
107
|
}
|
|
100
108
|
],
|
|
101
109
|
"allow": [
|
|
@@ -110,6 +118,12 @@
|
|
|
110
118
|
"fileName": "src/steps.ts",
|
|
111
119
|
"source": "export function steps(): void {\n step0();\n step1();\n step2();\n step3();\n step4();\n step5();\n step6();\n step7();\n step8();\n step9();\n step10();\n step11();\n step12();\n step13();\n step14();\n step15();\n step16();\n step17();\n step18();\n step19();\n step20();\n step21();\n step22();\n step23();\n step24();\n step25();\n step26();\n step27();\n step28();\n step29();\n step30();\n step31();\n step32();\n step33();\n step34();\n step35();\n step36();\n step37();\n step38();\n step39();\n step40();\n step41();\n step42();\n step43();\n if (ready0) {\n run();\n }\n if (ready1) {\n run();\n }\n if (ready2) {\n run();\n }\n}\n",
|
|
112
120
|
"expectedLines": []
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "a describe callback is not a function to shorten",
|
|
124
|
+
"fileName": "src/steps.test.ts",
|
|
125
|
+
"source": "describe(\"steps\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n});\n",
|
|
126
|
+
"expectedLines": []
|
|
113
127
|
}
|
|
114
128
|
]
|
|
115
129
|
}
|
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
|
|
package/rules/CD-6/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.** Keeps: [One word everywhere](../rules.md#one-word-everywhere); casing a check.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [One word everywhere](../rules.md#one-word-everywhere) and [Whole words](../typescript/recipes.md#whole-words).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A concept not yet understood.* `data` or `result` because the writer did not know what the value was. Find out, then name it.
|
|
15
|
-
- *A function returning a mix.* `result` is the only honest name because the function returns several things. Split it.
|
|
16
|
-
- *No shared vocabulary.* The team has no agreed words for the domain, so names fall back to shapes. Agree the terms and use them in code.
|
|
17
|
-
- *A framework's habit copied inward.* `req`, `res`, `e` from library examples. Name it for what it is in your code.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Every name states the concept, in the domain's words, at every scope.
|
|
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
|
-
- "Everyone knows what `i` means." They know it is an index, not an index of what.
|
|
23
|
-
- "Short scopes don't need long names." The rule covers every scope. The reader of a short scope still has to reconstruct the meaning.
|
|
24
|
-
- "It's the library's convention." Conventions belong at the boundary. Inside, use your words.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Intention-revealing names* (Robert C. Martin, *Clean Code*). A name should say why the thing exists and what it does, so no comment is needed.
|
|
28
|
-
- *Ubiquitous language* (Eric Evans, *Domain-Driven Design*). The code uses the same words as the people who know the domain.
|
|
15
|
+
Start from the symptom a finding names: [Shorthand name](../typescript/symptoms.md#shorthand-name) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing). 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-7/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-7 checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptoms: [Drawer path](../typescript/symptoms.md#drawer-path) 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
|
|
package/rules/CD-7/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: One reason per module; One word everywhere; filename case a check.
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [One reason per module](../rules.md#one-reason-per-module), [One word everywhere](../rules.md#one-word-everywhere) and [Screaming folders](../typescript/recipes.md#screaming-folders).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A concept nobody named.* The drawer holds functions that all serve one idea the codebase never named, such as money, dates or identifiers. Name the idea and give it a module.
|
|
15
|
-
- *Shared by accident.* Code moved to a common place because two callers needed it. Decide whether it belongs to one of them or is a concept of its own.
|
|
16
|
-
- *Shapes separated from their owners.* A types file holds shapes far from the code that uses them. Put each shape beside the code it describes.
|
|
17
|
-
- *Folders sorted by kind.* The tree groups things by what they are, not by what they do. Group by capability.
|
|
18
|
-
|
|
19
|
-
**Where to go.** Every file and folder name says what it holds, so a reader finds code by asking what it does. The rename is the small part; finding the concept behind it is the work.
|
|
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
|
-
- "It's just a name." The name is where the missing concept shows. A synonym such as "core" or "base" keeps the drawer.
|
|
23
|
-
- "The framework requires that path." Then authorise that path. What you add under it still needs a real home.
|
|
24
|
-
- "We'll sort it later." Category folders only grow.
|
|
13
|
+
## Spirit
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
- *Screaming architecture* (Robert C. Martin). The folder structure should tell a reader what the system does, not which kinds of file it contains.
|
|
28
|
-
- *Single Responsibility Principle* (Robert C. Martin, SOLID). A module has one reason to change. A drawer of unrelated helpers has as many reasons as it has helpers.
|
|
29
|
-
- *Primitive Obsession* (a code smell in Fowler's *Refactoring*). Helpers that all handle one raw value, such as an amount or a date string, usually mark a domain type nobody created.
|
|
15
|
+
Start from the symptom a finding names: [Drawer path](../typescript/symptoms.md#drawer-path) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing). 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) and [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language).
|
package/rules/CD-7a/CHECKS.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# CD-7a checks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Symptom: [Type derived from code](../typescript/symptoms.md#type-derived-from-code).
|
|
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-7a/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.** Symptom of [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries).
|
|
10
8
|
|
|
11
|
-
**
|
|
9
|
+
**Read.** [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries) and [Named, exported type](../typescript/recipes.md#named-exported-type).
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- *A contract nobody wrote down.* The factory's output was never named, so callers derive it. Name and export the type, and let the factory declare it returns that.
|
|
15
|
-
- *Implementation details leaking out.* The derived type exposes everything the factory builds. Declare only what callers should rely on.
|
|
16
|
-
- *A library with a named type you missed.* The package exports the type already. Use it.
|
|
17
|
-
|
|
18
|
-
**Where to go.** Every type the code produces has a name, and callers use the name.
|
|
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).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
- "Deriving keeps it in sync." It keeps it in sync with whatever the implementation does, including mistakes.
|
|
22
|
-
- "Naming it is duplication." The name is the contract; the implementation is one way to meet it.
|
|
13
|
+
## Spirit
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
- *Program to an interface, not an implementation* (Gamma, Helm, Johnson and Vlissides, *Design Patterns*). Callers depend on a declared contract, not on the shape the implementation produces.
|
|
26
|
-
- *Intention-revealing names* (Robert C. Martin, *Clean Code*). A named type says what the value is for.
|
|
15
|
+
Start from the symptom a finding names: [Type derived from code](../typescript/symptoms.md#type-derived-from-code). 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) and [The type checker proves it](../principles.md#the-type-checker-proves-it).
|