habit-hooks-generic 1.0.0__tar.gz

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.
Files changed (24) hide show
  1. habit_hooks_generic-1.0.0/.gitignore +20 -0
  2. habit_hooks_generic-1.0.0/PKG-INFO +5 -0
  3. habit_hooks_generic-1.0.0/docs/generic-plugin.spec.md +134 -0
  4. habit_hooks_generic-1.0.0/package-lock.json +1440 -0
  5. habit_hooks_generic-1.0.0/package.json +8 -0
  6. habit_hooks_generic-1.0.0/pyproject.toml +17 -0
  7. habit_hooks_generic-1.0.0/src/habit_hooks_generic/.jscpd.json +7 -0
  8. habit_hooks_generic-1.0.0/src/habit_hooks_generic/__init__.py +6 -0
  9. habit_hooks_generic-1.0.0/src/habit_hooks_generic/config.toml +1 -0
  10. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/deep-nesting.md +14 -0
  11. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/duplicated-code.md +14 -0
  12. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/high-complexity.md +10 -0
  13. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/non-essential-comment.md +8 -0
  14. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/oversized-file.md +10 -0
  15. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/oversized-function.md +10 -0
  16. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/parse-error.md +6 -0
  17. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/swallowed-exception.md +10 -0
  18. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/too-many-parameters.md +10 -0
  19. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/unused-export.md +8 -0
  20. habit_hooks_generic-1.0.0/src/habit_hooks_generic/guides/warning-comment.md +2 -0
  21. habit_hooks_generic-1.0.0/src/habit_hooks_generic/sensors/jscpd.py +71 -0
  22. habit_hooks_generic-1.0.0/src/habit_hooks_generic/sensors/jscpd.toml +1 -0
  23. habit_hooks_generic-1.0.0/src/habit_hooks_generic/sensors/line-count.py +50 -0
  24. habit_hooks_generic-1.0.0/src/habit_hooks_generic/sensors/line-count.toml +2 -0
@@ -0,0 +1,20 @@
1
+ # Per-plugin Node tool deps (installed via npm ci; see plugins/*/package.json)
2
+ node_modules/
3
+ dist
4
+ coverage
5
+ .DS_Store
6
+ .idea
7
+ .claude-channel/
8
+ *.tgz
9
+ *.log
10
+ .vscode/
11
+ .venv/
12
+ __pycache__/
13
+ *.pyc
14
+ .pytest_cache/
15
+ .spec-runs/
16
+
17
+ /ruff.toml
18
+
19
+ # Workflow orchestration script (run from ~/.claude, never a repo deliverable)
20
+ .claude/workflows-build-overnight.js
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: habit-hooks-generic
3
+ Version: 1.0.0
4
+ Summary: The generic (language-agnostic) Habit Hooks plugin
5
+ Requires-Python: >=3.11
@@ -0,0 +1,134 @@
1
+ # The generic plugin β€” acceptance
2
+
3
+ The generic plugin runs language-agnostic sensors through the real `habit-sensors`
4
+ pipeline. These cases run the **actual** tools against a fixture with a known
5
+ smell and assert the canonical finding comes out.
6
+
7
+ The Node tools live in `plugins/generic/node_modules`; the intro symlinks that
8
+ into each case as `./node_modules` and puts its `.bin` on `PATH` once.
9
+
10
+ πŸ“„.habit-hooks/config.toml
11
+ ```toml
12
+ plugins = ["generic"]
13
+ ```
14
+
15
+ ```bash
16
+ ln -s ../../plugins/generic/node_modules node_modules
17
+ ```
18
+
19
+ ✏️PATH
20
+ ```text
21
+ $PWD/node_modules/.bin:$PATH
22
+ ```
23
+
24
+ ## line-count emits oversized-file over the threshold
25
+
26
+ The `line-count` sensor flags a file longer than its `--max` threshold (default
27
+ 200, shipped as replace-on-override `args` in `sensors/line-count.toml`) as
28
+ `oversized-file`.
29
+
30
+ πŸ“„.habit-hooks/config.toml
31
+ ```toml
32
+ plugins = ["generic"]
33
+ files = ["**/*.py"]
34
+
35
+ [sensors.jscpd]
36
+ disabled = true
37
+ ```
38
+
39
+ ```bash
40
+ seq 1 205 | sed 's/^/x/;s/$/ = 0/' > big.py
41
+ habit-sensors --all | jq '.[] | {smell, max: .details.maxAllowed, key: .issues[0].key, lines: .issues[0].details.lines}'
42
+ ```
43
+
44
+ πŸ–₯️ βœ…
45
+ ```json
46
+ {
47
+ "smell": "oversized-file",
48
+ "max": 200,
49
+ "key": "big.py",
50
+ "lines": 205
51
+ }
52
+ ```
53
+
54
+ ## line-count threshold is replace-on-override
55
+
56
+ A project `[sensors.line-count] args` replaces the shipped `--max 200` cleanly, so
57
+ a 205-line file no longer fires once the threshold is raised.
58
+
59
+ πŸ“„.habit-hooks/config.toml
60
+ ```toml
61
+ plugins = ["generic"]
62
+ files = ["**/*.py"]
63
+
64
+ [sensors.jscpd]
65
+ disabled = true
66
+
67
+ [sensors.line-count]
68
+ args = ["--max", "300"]
69
+ ```
70
+
71
+ ```bash
72
+ seq 1 205 | sed 's/^/x/;s/$/ = 0/' > big.py
73
+ habit-sensors --all | jq .
74
+ ```
75
+
76
+ πŸ–₯️ βœ…
77
+ ```json
78
+ []
79
+ ```
80
+
81
+ ## jscpd emits duplicated-code for a cloned block
82
+
83
+ The `jscpd` sensor wraps the real jscpd CLI and shapes each clone into a
84
+ `duplicated-code` finding listing both occurrences in `issues`. The plugin ships
85
+ `.jscpd.json` (`path: ["src"]`, `minLines: 5`, `minTokens: 50`, `threshold: 0`),
86
+ so jscpd scans `src` and reports the duplicated block.
87
+
88
+ πŸ“„.habit-hooks/config.toml
89
+ ```toml
90
+ plugins = ["generic"]
91
+
92
+ [sensors.line-count]
93
+ disabled = true
94
+ ```
95
+
96
+ πŸ“„src/a.ts
97
+ ```typescript
98
+ export function alpha(x: number, y: number) {
99
+ const sum = x + y;
100
+ const product = x * y;
101
+ const diff = x - y;
102
+ const quotient = x / y;
103
+ const scaled = sum * product;
104
+ return { sum, product, diff, quotient };
105
+ }
106
+ ```
107
+
108
+ πŸ“„src/b.ts
109
+ ```typescript
110
+ export function beta(x: number, y: number) {
111
+ const sum = x + y;
112
+ const product = x * y;
113
+ const diff = x - y;
114
+ const quotient = x / y;
115
+ const scaled = sum * product;
116
+ return { sum, product, diff, quotient };
117
+ }
118
+ ```
119
+
120
+ ```bash
121
+ habit-sensors --all | jq '.[] | {smell, files: [.issues[].key | sub(".*/"; "")], source: .issues[0].details.source}'
122
+ ```
123
+
124
+ πŸ–₯️ βœ…
125
+ ```json
126
+ {
127
+ "smell": "duplicated-code",
128
+ "files": [
129
+ "a.ts",
130
+ "b.ts"
131
+ ],
132
+ "source": "jscpd:duplication"
133
+ }
134
+ ```