@leing2021/super-pi 0.30.4 → 0.30.5
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/package.json
CHANGED
|
@@ -32,6 +32,14 @@ Each entry reads *what it is* → *how to fix*. Match against the diff, not the
|
|
|
32
32
|
- **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
|
33
33
|
- **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
|
34
34
|
|
|
35
|
+
## Dependency-axis tags (reinvented-wheel check)
|
|
36
|
+
|
|
37
|
+
The 12 smells above cover structure; these three catch **rebuilding what already exists**. Same binding rules apply (repo overrides, always a judgement call, default P2). One line per finding: location, what to cut, what replaces it.
|
|
38
|
+
|
|
39
|
+
- **`stdlib:`** — hand-rolled code the language's standard library already ships. → name the function that replaces it (e.g. a manual loop building a dict vs `dict(zip(keys, values))`; hand-rolled path joining vs `pathlib`).
|
|
40
|
+
- **`native:`** — a dependency or custom code doing what the platform already provides. → name the native feature (e.g. moment.js for one format call vs `Intl.DateTimeFormat`; a JS date-picker lib vs `<input type="date">`; app-level uniqueness checks vs a DB constraint).
|
|
41
|
+
- **`dependency:`** — a new package added for what a few lines or an already-installed dependency can do. → inline it or use the existing dep; add the new one only when the hand-rolled version grows real complexity.
|
|
42
|
+
|
|
35
43
|
## What is deliberately NOT here
|
|
36
44
|
|
|
37
45
|
These are Fowler's file-level smells, **excluded from the review baseline** because they read against a whole file, not a diff — weak signal in a diff-based review. They belong in architecture audit (`references/module-design.md`) and `03-work` REFACTOR, not in `04-review` Standards axis:
|
|
@@ -32,6 +32,34 @@ Rationale: Immutable data prevents hidden side effects, makes debugging easier,
|
|
|
32
32
|
- Avoid speculative generality
|
|
33
33
|
- Start simple, then refactor when the pressure is real
|
|
34
34
|
|
|
35
|
+
### The Ladder
|
|
36
|
+
|
|
37
|
+
Before writing code, stop at the **first rung that holds**:
|
|
38
|
+
|
|
39
|
+
1. Does this need to exist at all? → No: skip it, say so in one line (YAGNI)
|
|
40
|
+
2. Already in this codebase? → Reuse it. Search before writing; re-implementing what exists a few files over is the most common slop
|
|
41
|
+
3. stdlib does it? → Use it
|
|
42
|
+
4. Platform-native feature covers it? → Use it (native input over a picker lib, CSS over JS, DB constraint over app code)
|
|
43
|
+
5. Already-installed dependency solves it? → Use it. Never add a new one for what a few lines can do
|
|
44
|
+
6. Can it be one line? → One line
|
|
45
|
+
7. Only then: the minimum code that works
|
|
46
|
+
|
|
47
|
+
Meta-rules:
|
|
48
|
+
- The ladder runs **after** understanding the problem, not instead of it. Lazy about writing, never about reading — trace every file the change touches first.
|
|
49
|
+
- Bug fix = **root cause**, not symptom. The root-cause fix is usually the smaller diff: one guard in the shared function beats a guard in every caller.
|
|
50
|
+
|
|
51
|
+
Never simplify away: trust-boundary validation, error handling that prevents data loss, security, accessibility, anything explicitly requested.
|
|
52
|
+
|
|
53
|
+
### Debt marker
|
|
54
|
+
|
|
55
|
+
When deliberately cutting a corner with a known ceiling (global lock, O(n²) scan, naive heuristic), mark it:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
// debt: global lock, upgrade when per-account throughput matters
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Name the ceiling and the trigger. A `debt:` marker with no upgrade condition is rot risk, not minimalism. Audit with `rg 'debt:'`.
|
|
62
|
+
|
|
35
63
|
## File Organization
|
|
36
64
|
|
|
37
65
|
MANY SMALL FILES > FEW LARGE FILES:
|