@blundergoat/gruff-ts 0.4.0 → 0.6.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/CONTRIBUTING.md +32 -25
  3. package/README.md +55 -46
  4. package/SECURITY.md +18 -30
  5. package/UPGRADING.md +101 -0
  6. package/bin/gruff-ts +3 -0
  7. package/docs/README.md +11 -13
  8. package/docs/agent-hook.md +33 -24
  9. package/docs/ci-integration.md +38 -24
  10. package/docs/configuration.md +173 -71
  11. package/docs/dashboard.md +12 -13
  12. package/docs/output-formats.md +100 -25
  13. package/docs/philosophy.md +2 -2
  14. package/docs/reports-and-ci.md +14 -157
  15. package/docs/rules.md +140 -106
  16. package/package.json +10 -8
  17. package/src/analyser.ts +886 -282
  18. package/src/baseline-file.ts +867 -0
  19. package/src/baseline-identity.ts +463 -0
  20. package/src/baseline-options.ts +139 -34
  21. package/src/baseline.ts +85 -55
  22. package/src/blocks.ts +579 -364
  23. package/src/changed-regions.ts +414 -65
  24. package/src/check-ignore.ts +28 -13
  25. package/src/class-rules.ts +461 -302
  26. package/src/cli-program.ts +956 -166
  27. package/src/cli.ts +9 -2
  28. package/src/comment-rules.ts +277 -414
  29. package/src/comment-scanner.ts +363 -44
  30. package/src/complexity-metrics.ts +320 -0
  31. package/src/config-load-error.ts +17 -8
  32. package/src/config-parse.ts +291 -98
  33. package/src/config-preservation.ts +81 -26
  34. package/src/config.ts +778 -210
  35. package/src/constants.ts +7 -6
  36. package/src/context-doc-rules.ts +188 -61
  37. package/src/dashboard.ts +88 -23
  38. package/src/dead-code-rules.ts +153 -74
  39. package/src/discovery.ts +521 -148
  40. package/src/doc-rules.ts +592 -147
  41. package/src/duplicate-test-group-rules.ts +359 -0
  42. package/src/findings-helpers.ts +240 -89
  43. package/src/findings.ts +48 -24
  44. package/src/fixture-purpose-rules.ts +226 -48
  45. package/src/github-actions-event-guards.ts +331 -0
  46. package/src/github-actions-rules.ts +336 -106
  47. package/src/hook-contract.ts +708 -211
  48. package/src/init-config.ts +169 -114
  49. package/src/inline-suppressions.ts +340 -0
  50. package/src/limit-band.ts +56 -0
  51. package/src/line-rules.ts +331 -419
  52. package/src/migrate-config.ts +670 -0
  53. package/src/naming-pushers.ts +33 -107
  54. package/src/parsed-script.ts +1206 -0
  55. package/src/pillar-summary.ts +56 -40
  56. package/src/profiles.ts +97 -71
  57. package/src/project-config-rules.ts +335 -146
  58. package/src/project-rules.ts +237 -115
  59. package/src/public-exports.ts +284 -0
  60. package/src/report-html.ts +217 -85
  61. package/src/report-renderers.ts +864 -195
  62. package/src/rule-list.ts +166 -46
  63. package/src/rules.ts +100 -104
  64. package/src/safety-rules.ts +191 -132
  65. package/src/scoring.ts +255 -52
  66. package/src/security-flow-rules.ts +930 -109
  67. package/src/selectors.ts +169 -0
  68. package/src/sensitive-data-rules.ts +502 -375
  69. package/src/sensitive-exclusions.ts +435 -0
  70. package/src/source-text.ts +380 -148
  71. package/src/static-analysis-redundant-rules.ts +298 -41
  72. package/src/test-block-rules.ts +422 -228
  73. package/src/text-scans.ts +67 -9
  74. package/src/types.ts +222 -71
  75. package/tsconfig.json +2 -1
  76. package/src/process-exec-metadata.ts +0 -153
  77. package/src/test-fixtures.ts +0 -668
@@ -6,7 +6,7 @@ thresholds that need tuning.
6
6
 
7
7
  ## Discovery Order
8
8
 
9
- `analyse` auto-loads the first supported config file it finds in the project root:
9
+ `analyse`, `summary`, `report`, and `hook` auto-load the first supported config file in the project root:
10
10
 
11
11
  1. `.gruff-ts.yaml`
12
12
  2. `.gruff.json`
@@ -29,41 +29,50 @@ gruff-ts analyse . --no-config
29
29
 
30
30
  Every `.gruff-ts.yaml` must declare `schemaVersion: gruff-ts.config.v0.1` at the
31
31
  top. Loading throws if the field is missing or carries a different value. The
32
- field is in a different namespace from the output schemas (`gruff.analysis.v2`,
33
- `gruff.summary.v2`, etc.) - the config-input version travels independently of
32
+ field is in a different namespace from the output schemas (`gruff.analysis.v3`,
33
+ `gruff.summary.v3`, etc.) - the config-input version travels independently of
34
34
  the output-payload versions. See ADR-004.
35
35
 
36
- ## minimumSeverity (per-command gating defaults)
36
+ ## failOn (per-command gating defaults)
37
37
 
38
- A top-level `minimumSeverity:` block sets the default `--fail-on` value per
39
- command. The precedence chain is **CLI flag > config > binary default**.
38
+ A top-level `failOn:` block sets the default `--fail-on` value per command.
39
+ The precedence chain is **CLI flag > config > binary default**.
40
40
 
41
41
  ```yaml
42
42
  schemaVersion: gruff-ts.config.v0.1
43
- minimumSeverity:
43
+ failOn:
44
44
  analyse: advisory
45
- summary: advisory
45
+ summary: none
46
46
  report: none
47
47
  ```
48
48
 
49
- Valid values: `advisory | warning | error | none`. The validator rejects any
50
- other value (including `never`, which was an early cross-port draft for the
51
- off-switch before the family converged on `none`).
49
+ Valid values: `advisory | warning | error | none`; anything else, `never`
50
+ included, is rejected.
52
51
 
53
- `dashboard` is intentionally **not** a valid key in this block. The dashboard
54
- subcommand has no `--fail-on` flag today; setting `minimumSeverity.dashboard:`
55
- would be a silent no-op CI footgun, so the validator rejects it with a clear
56
- error.
52
+ `dashboard` is not a valid key. It has no `--fail-on` flag, so
53
+ `failOn.dashboard:` fails validation instead of being silently ignored.
57
54
 
58
- Binary defaults are `analyse: advisory`, `summary: advisory`, `report: none`.
55
+ Binary defaults are `analyse: advisory`, `summary: none`, `report: none`.
56
+
57
+ Across the Gruff family only `analyse` and `report` are accepted by every port, so a
58
+ polyglot repository that shares one `failOn` block should write only those two keys.
59
+ `summary` is accepted by gruff-go and gruff-ts, and `dashboard` by gruff-go, gruff-php
60
+ and gruff-py; each other port refuses the key with exit 2 rather than ignoring it,
61
+ because it ships no gate for that command.
62
+
63
+ `minimumSeverity:` is a different setting: one severity - `advisory`,
64
+ `warning`, or `error` - that hides quieter findings from the report without
65
+ changing the score or the exit code. A `minimumSeverity:` carrying the
66
+ per-command map above is refused at config load rather than read as a floor, so
67
+ an existing 0.5 config cannot quietly change what it gates.
59
68
 
60
69
  ## Shape
61
70
 
62
71
  ```yaml
63
72
  schemaVersion: gruff-ts.config.v0.1
64
- minimumSeverity:
73
+ failOn:
65
74
  analyse: advisory
66
- summary: advisory
75
+ summary: none
67
76
  report: none
68
77
 
69
78
  paths:
@@ -74,17 +83,15 @@ allowlists:
74
83
  acceptedAbbreviations:
75
84
  - api
76
85
  - cli
77
- secretPreviews: []
78
- bannedGenericNames: [process, handle, doit, run, execute, manage]
79
- acceptedBooleanNames: [all, apply, check, dev, enabled, force, fresh, harness, json, ok, verbose, yes]
80
- booleanPrefixes: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires, allow, check, enable, exclude, include, omit, skip, with, without]
81
- hungarianPrefixes: [str, obj, arr, bool, int, num]
82
86
  placeholderNames: [foo, bar, baz, tmp, temp, thing, stuff, data, value, item]
83
- negativeBooleanAllowed: [nostore, nofollow, noreferrer, noscript, noindex]
84
- knownAcronyms: [url, http, https, id, xml, json, html, css, api, sql, db, io, ui, uuid, ip, tcp, udp, ast, cli, npm]
87
+
88
+ sensitiveExclusions:
89
+ - rule: sensitive-data.aws-access-key
90
+ path: tests/fixtures/aws-sample.env
91
+ reason: Synthetic key used by the loader fixture; not a live credential.
85
92
 
86
93
  rules:
87
- rule.id:
94
+ complexity.cyclomatic:
88
95
  enabled: true
89
96
  threshold: 10
90
97
  severity: warning
@@ -108,22 +115,37 @@ paths:
108
115
  - "src/generated-client.ts"
109
116
  ```
110
117
 
111
- Default ignored directories are matched by first path segment:
118
+ VCS internals are always blocked at any depth:
112
119
 
113
120
  ```text
114
- .git, .hg, .svn, .idea, .vscode, build, cache, coverage, dist,
115
- generated, node_modules, target, tmp, vendor
121
+ .git, .hg, .svn
116
122
  ```
117
123
 
118
- Use `--include-ignored` when you intentionally want to scan default ignored
119
- directories and Git-ignored paths. Configured `paths.ignore` entries still
120
- apply - `--include-ignored` never overrides them.
124
+ Third-party copies, build output and minified files are skipped at any depth and
125
+ in any letter case, even when a `.gitignore` exists: directories named `vendor`,
126
+ `vendors`, `third_party`, `third-party` or `bower_components` (reason
127
+ `dependency`) or `dist` (reason `build-output`), and files with `.min.` directly
128
+ before the final extension, such as `jquery.min.js` (reason `generated`).
129
+
130
+ When no `.gitignore` exists from the project root through a candidate's parent,
131
+ the family fallback also skips `.fleet`, `.idea`, `.vscode`, `build`, `coverage`,
132
+ and `node_modules` at any depth. Once a `.gitignore` exists in that chain, it
133
+ owns those names for the subtree. Committed control metadata such
134
+ as `.agents`, `.claude`, `.codex`, `.github`, and `.goat-flow` stays scannable
135
+ unless Git or config excludes it.
136
+
137
+ Use `--include-ignored` when you intentionally want to scan third-party,
138
+ fallback and Git-ignored paths. An explicit supported file also bypasses those
139
+ three layers.
140
+ Neither form overrides configured `paths.ignore` or the VCS boundary. Lockfile
141
+ names add no exclusion; eligible forms such as `package-lock.json` are scanned.
121
142
 
122
143
  `paths.ignore` is authoritative in every invocation mode (ADR-007): a matching
123
144
  path is excluded and produces no findings whether it is reached by a directory
124
145
  walk, passed as an explicit file operand (`gruff-ts analyse src/generated-client.ts`),
125
146
  or touched by a diff/changed-region run. Excluded paths appear in the report's
126
- `paths.skipped` array with their `source` (`config` / `gitignore` / `default`) and
147
+ `paths.details` array with their `source` (`config` / `gitignore` / `default`) and, for
148
+ `config` entries only,
127
149
  the matching `pattern`. Query a path without scanning via `check-ignore`, which
128
150
  shares the same engine and mirrors `git check-ignore` exit codes (0 = at least
129
151
  one ignored, 1 = none, 2 = error):
@@ -135,8 +157,9 @@ gruff-ts check-ignore src/generated-client.ts --format json
135
157
 
136
158
  ## Generated Markers
137
159
 
138
- Use `paths.ignore` when a generated or vendored surface should not be scanned at
139
- all. If the file should stay in the scan, gruff treats a source file as generated
160
+ Vendored directories, `dist` and `.min.` files are already skipped (see above).
161
+ Use `paths.ignore` when any other generated or vendored surface should not be
162
+ scanned at all. If the file should stay in the scan, gruff treats a source file as generated
140
163
  only when one of these explicit markers appears in the first 10 lines:
141
164
  `AUTO-GENERATED`, `@generated`, `GENERATED FILE`, `Code generated`,
142
165
  `Generated by`, `DO NOT EDIT`, or `Copied from`.
@@ -144,9 +167,10 @@ only when one of these explicit markers appears in the first 10 lines:
144
167
  Generated files skip documentation and naming findings only. Security,
145
168
  sensitive-data, size, complexity, maintainability, modernisation, and
146
169
  test-quality checks still run, so a generated file can still report a leaked
147
- credential, unsafe execution, or a file-size finding. Path names such as
148
- `fixtures/`, `testdata/`, or `perf-tests/` do not by themselves suppress any
149
- rule family.
170
+ credential, unsafe execution, or a file-size finding. Directory names alone never
171
+ trigger this generated-file skip (separately, security and sensitive-data rules
172
+ skip test, fixture, and example paths with counted audit rows - see Sensitive
173
+ Exclusions below).
150
174
 
151
175
  ## Allowlists
152
176
 
@@ -161,35 +185,49 @@ allowlists:
161
185
  - env
162
186
  ```
163
187
 
164
- `allowlists.secretPreviews` accepts redacted secret previews that are known false
165
- positives:
188
+ The `0.5` key `allowlists.secretPreviews` is removed because reports now use
189
+ fixed category markers unconditionally, without matched characters or
190
+ secret-derived lengths. `gruff-ts init` no longer writes it, configs containing
191
+ it (even as an empty list) fail with exit `2`, and `gruff-ts migrate-config`
192
+ deletes it. To silence a reviewed sample secret, use `sensitiveExclusions:`
193
+ below rather than preview matching.
166
194
 
167
- ```yaml
168
- allowlists:
169
- secretPreviews:
170
- - "abcd...wxyz (redacted, 32 chars)"
171
- ```
172
-
173
- Prefer fixing false positives with a narrow config entry instead of disabling an
174
- entire sensitive-data rule.
175
-
176
- Naming allowlists tune the 0.2.0 naming pack without changing rule ids or
195
+ Naming allowlists tune the naming rules without changing rule IDs or
177
196
  fingerprints:
178
197
 
179
198
  | Key | Used by | Default behavior |
180
199
  | --- | --- | --- |
181
200
  | `acceptedAbbreviations` | `naming.short-variable` | Adds short names that should not be flagged. |
182
- | `acceptedBooleanNames` | `naming.boolean-prefix` | Replaces exact public/CLI/DTO boolean names such as `verbose`, `enabled`, `ok`, and `force`. |
183
- | `bannedGenericNames` | `naming.generic-function` | Replaces the built-in generic function-name denylist. |
184
- | `booleanPrefixes` | `naming.boolean-prefix` | Replaces the accepted boolean-name prefixes such as `is`, `has`, `should`, `may`, `supports`, and `requires`. |
185
- | `hungarianPrefixes` | `naming.hungarian-notation` | Replaces type-style prefixes to flag. |
186
- | `placeholderNames` | `naming.identifier-quality`, `naming.generic-parameter` | Replaces placeholder words; numbered suffix checks stay active. |
187
- | `negativeBooleanAllowed` | `naming.negative-boolean` | Replaces domain terms allowed to start with `no`. |
188
- | `knownAcronyms` | `naming.acronym-case` | Replaces acronyms checked for mixed casing. |
201
+ | `acceptedClassFilePairs` | `naming.class-file-mismatch` | Replaces the exact case-insensitive `fileBase:ClassName` pairs that may use feature-file and class-role naming. Defaults to empty. |
202
+ | `placeholderNames` | `naming.identifier-quality` | Replaces placeholder words; numbered suffix checks stay active. |
189
203
 
190
204
  For replace-style allowlists, use an empty list (`[]`) when you intentionally
191
205
  want no entries.
192
206
 
207
+ Use an exact pair allowlist when a class and its file must keep different names:
208
+
209
+ ```yaml
210
+ allowlists:
211
+ acceptedClassFilePairs: ["focusModeTranscript:TranscriptFocusController"]
212
+ ```
213
+
214
+ The entry uses the extensionless file base before the colon. The list is
215
+ case-insensitive, replaces the complete configured list, and suppresses only the
216
+ exact pair rather than every name sharing the same canonical form.
217
+
218
+ `allowlists.trackingTokens` lists a project's own tracking references as regular
219
+ expressions. `docs.todo-without-tracking` treats a marker comment that matches
220
+ one as tracked, and `modernisation.ts-comment-without-rationale` and
221
+ `waste.swallowed-catch` accept a match as a rationale. gruff-ts ships no
222
+ project-specific token; to accept a reference style such as `ADR-004`, list a
223
+ pattern for it:
224
+
225
+ ```yaml
226
+ allowlists:
227
+ trackingTokens:
228
+ - "ADR-[0-9]+"
229
+ ```
230
+
193
231
  ## Rule Controls
194
232
 
195
233
  Disable a rule:
@@ -200,11 +238,14 @@ rules:
200
238
  enabled: false
201
239
  ```
202
240
 
203
- Set one threshold and one emitted severity for a metric rule:
241
+ Set one threshold and one emitted severity for a metric rule. A rule that is
242
+ off by default, such as `complexity.cyclomatic`, also needs `enabled: true`; a
243
+ threshold alone does not turn it on:
204
244
 
205
245
  ```yaml
206
246
  rules:
207
247
  complexity.cyclomatic:
248
+ enabled: true
208
249
  threshold: 10
209
250
  severity: warning
210
251
  size.file-length:
@@ -225,6 +266,9 @@ rules:
225
266
  minLines: 80
226
267
  ```
227
268
 
269
+ Any other key inside a rule block, a sibling port's `thresholds` map included, fails the config load
270
+ and names the key and the keys the block accepts.
271
+
228
272
  List supported thresholds and options:
229
273
 
230
274
  ```bash
@@ -234,9 +278,79 @@ gruff-ts list-rules --format=json
234
278
 
235
279
  See [Rules](./rules.md) for the full rule catalogue grouped by pillar.
236
280
 
281
+ ## Sensitive Exclusions
282
+
283
+ `sensitiveExclusions:` is the only setting that suppresses a sensitive-data finding. It
284
+ is a separate top-level section, not part of `rules:` or `paths.ignore`, because
285
+ it is the one surface that can hide a detected secret.
286
+
287
+ One built-in skip also hides findings, and counts each one in `suppressions`:
288
+ every sensitive-data and security rule in test, fixture and example files.
289
+ A configured entry applies first, so a finding it claims is counted under the entry.
290
+
291
+ You write every entry by hand. Gruff never converts a detected value, a preview,
292
+ or a finding message into an exclusion, and no key on an entry matches against
293
+ finding text.
294
+
295
+ ```yaml
296
+ sensitiveExclusions:
297
+ - rule: sensitive-data.aws-access-key
298
+ path: tests/fixtures/aws-sample.env
299
+ reason: Synthetic key used by the loader fixture; not a live credential.
300
+ ```
301
+
302
+ An entry suppresses a finding only when all of the following match:
303
+
304
+ - `rule` equals the finding's rule id exactly. One rule id per entry, from the
305
+ `sensitive-data` pillar only.
306
+ - `path` equals the finding's project-relative path exactly. One file per entry.
307
+ - `symbol`, when present, equals the finding's symbol exactly. It narrows the
308
+ scope. No sensitive-data rule stamps a symbol today, so an entry carrying one
309
+ currently matches nothing - that is the declared scope working, not a bug.
310
+
311
+ Nothing else is suppressed: the same rule in another file, and a different rule
312
+ in the same file, both keep reporting.
313
+
314
+ `reason` is required and must be non-empty. Loading fails with exit code 2 and
315
+ names the entry index plus the offending key when an entry:
316
+
317
+ - omits `rule`, or gives a wildcard, glob, regular-expression character, pillar
318
+ name, unknown rule id, or a rule outside the `sensitive-data` pillar;
319
+ - omits `path`, or gives an absolute path, a `..` traversal, or a glob;
320
+ - carries any key outside `rule`, `path`, `symbol`, and `reason` - including
321
+ `message_contains`, `messageContains`, `value`, and `preview`;
322
+ - omits `reason` or supplies only whitespace;
323
+ - repeats a `rule` + `path` + `symbol` scope an earlier entry already claims.
324
+
325
+ An entry that matches no finding is not an error. It reports `suppressed: 0`, so
326
+ fixing the underlying problem never breaks a build.
327
+
328
+ Every entry is counted. The `suppressions` array in the `gruff.analysis.v3`
329
+ report carries one row per entry in declaration order:
330
+
331
+ ```json
332
+ { "index": 0, "rule": "sensitive-data.aws-access-key", "paths": ["tests/fixtures/aws-sample.env"], "reason": "Synthetic key used by the loader fixture; not a live credential.", "suppressed": 2 }
333
+ ```
334
+
335
+ Text output prints the total when it is non-zero:
336
+
337
+ ```text
338
+ Suppressed findings: 2 via sensitiveExclusions[0] sensitive-data.aws-access-key: 2 (Synthetic key used by the loader fixture; not a live credential.)
339
+ ```
340
+
341
+ A suppressed finding leaves the finding list, the score, and the `--fail-on`
342
+ exit code, but it is never invisible: its count is always reported. Only the
343
+ configured rule id, path, and reason appear in output - never any part of the
344
+ detected value.
345
+
237
346
  ## Example Project Config
238
347
 
348
+ A complete file. The shorter snippets above omit `schemaVersion` because they
349
+ show a single key in isolation; every real `.gruff-ts.yaml` needs it.
350
+
239
351
  ```yaml
352
+ schemaVersion: gruff-ts.config.v0.1
353
+
240
354
  paths:
241
355
  ignore:
242
356
  - "generated/**"
@@ -248,24 +362,12 @@ allowlists:
248
362
  - cli
249
363
  - env
250
364
  - id
251
- acceptedBooleanNames:
252
- - verbose
253
- - enabled
254
- secretPreviews: []
255
365
 
256
366
  rules:
257
- complexity.cognitive:
258
- threshold: 15
259
- severity: warning
260
367
  complexity.cyclomatic:
368
+ enabled: true
261
369
  threshold: 10
262
370
  severity: warning
263
- design.deep-relative-import:
264
- threshold: 2
265
- severity: advisory
266
- sensitive-data.high-entropy-string:
267
- threshold: 32
268
- severity: error
269
371
  size.function-length:
270
372
  threshold: 30
271
373
  severity: warning
package/docs/dashboard.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Dashboard
2
2
 
3
- `gruff-ts dashboard` serves a local browser dashboard for repeated analysis.
3
+ `gruff-ts dashboard` starts a local web UI for running and inspecting scans interactively.
4
4
 
5
5
  ## Start
6
6
 
7
7
  ```sh
8
- ./bin/gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
8
+ npx gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
9
9
  ```
10
10
 
11
11
  ## Options
@@ -16,21 +16,20 @@
16
16
  | `--port` | `8767` | Bind port. |
17
17
  | `--project-root` | current directory | Initial project root. |
18
18
 
19
+ ## Routes
20
+
21
+ - `/` - iframe shell and controls panel.
22
+ - `/health` - plain `ok`.
23
+ - `/scan?projectRoot=<path>&path=<path>` - report HTML for the selected scan.
24
+
19
25
  ## Safety
20
26
 
21
- The dashboard has no authentication and should stay bound to loopback unless the
22
- network is trusted. The `/scan` endpoint analyses filesystem paths from request
23
- parameters, so the bind address is the safety boundary.
27
+ The dashboard has no authentication. Keep it bound to `127.0.0.1` unless you trust every machine on the network: its `/scan` endpoint reads filesystem paths from request parameters, so loopback binding is the main safety boundary.
24
28
 
25
- ## Gating threshold (none)
29
+ ## No Gating Threshold
26
30
 
27
- `dashboard` has no `--fail-on` flag and does not participate in the
28
- `minimumSeverity:` config block - setting `minimumSeverity.dashboard:` in
29
- `.gruff-ts.yaml` is rejected at config load. Whether the dashboard should gate
30
- is a deferred design question; raise it as an issue if your workflow needs it.
31
+ `dashboard` has no `--fail-on` flag and cannot appear under `failOn:` in `.gruff-ts.yaml` (setting `failOn.dashboard:` fails config validation with exit `2`).
31
32
 
32
33
  ## Polyglot Repos
33
34
 
34
- `gruff-ts` defaults to port `8767`, `gruff-rs` defaults to `8766`, and Go, PHP,
35
- and Python default to `8765`. Use `--port` when running multiple dashboards at
36
- once.
35
+ `gruff-ts` defaults to port `8767`, `gruff-rs` to `8766`, and `gruff-go`, `gruff-php`, and `gruff-py` to `8765`. Pass `--port` if you run several dashboards side by side.
@@ -1,46 +1,113 @@
1
1
  # Output Formats
2
2
 
3
- `gruff-ts analyse --format <format>` renders the same analysis data for
4
- different consumers. The combined legacy page remains at
5
- [Reports And CI](reports-and-ci.md).
3
+ `gruff-ts analyse --format <format>` renders the same scan results for different
4
+ consumers.
6
5
 
7
6
  ## Text
8
7
 
9
8
  Use `text` for local terminal scans:
10
9
 
11
10
  ```sh
12
- ./bin/gruff-ts analyse src --format text --fail-on=warning
11
+ npx gruff-ts analyse src --format text --fail-on=warning
13
12
  ```
14
13
 
15
14
  ## JSON
16
15
 
17
- Use `json` for automation. JSON reports use `gruff.analysis.v2`.
16
+ Use `json` for automation. Analysis reports emit `gruff.analysis.v3`:
18
17
 
19
18
  ```sh
20
- ./bin/gruff-ts analyse src --format=json --fail-on=none > gruff-ts.json
19
+ npx gruff-ts analyse src --format=json --fail-on=none > gruff-ts.json
21
20
  ```
22
21
 
23
- `paths.skipped` (added in 0.3.0) lists every excluded path with its ignore
24
- `source` (`config` / `gitignore` / `default`) and the matching `pattern`;
25
- `paths.ignoredPaths` remains as the back-compatible `string[]` of the same paths.
26
- The field is additive, so existing `gruff.analysis.v2` consumers are unaffected.
27
-
28
- Score math clusters correlated `complexity.cognitive`,
29
- `complexity.cyclomatic`, and `size.function-length` findings once per function
30
- symbol. The detailed `findings` array still lists each rule finding; only pillar
31
- penalties and offender scores are de-duplicated.
22
+ Version 3 is a coordinated family contract and a hard break from the `0.5.x` v2
23
+ envelope. Paths are project-relative POSIX strings, `run.projectRoot` is `.`,
24
+ and volatile generation timestamps are omitted. Update consumers for these field
25
+ changes:
26
+
27
+ | v2 | v3 |
28
+ |---|---|
29
+ | `findings[].filePath` and `findings[].file` | `findings[].file` |
30
+ | `score.composite` plus `score.grade` | `score.composite.score` plus `score.composite.grade` |
31
+ | `score.topOffenders[].filePath` | `score.topOffenders[].file` |
32
+ | `paths.skipped` | `paths.details` |
33
+ | top-level `notes` | `extensions.ts.topLevel.notes` |
34
+ | `baseline.suppressed` | `baseline.suppressedFindings` |
35
+ | top-level `suppressedCount` | `diff.filteredFindings` and `summary.suppressedFindings` |
36
+ | `generatedAt` | omitted |
37
+
38
+ Optional `column`, `endLine`, and `symbol` fields are omitted when unavailable
39
+ rather than set to `null`. Finding metadata sets `locationPrecision` to
40
+ `scanner-pinpointed` or `line-only`. Baseline identities follow the line-free v3
41
+ contract introduced in `0.6.0` (see [Upgrading](../UPGRADING.md)) and stay
42
+ stable across output formats and ordinary edits.
43
+
44
+ ### Suppressions audit
45
+
46
+ The `suppressions` array is always present (empty when nothing was configured or
47
+ suppressed) and groups audit rows in three ordered sections:
48
+
49
+ 1. **Configured exclusions** - one row per `sensitiveExclusions:` entry in
50
+ declaration order (`{index, rule, paths, symbol?, reason, suppressed}`). See
51
+ [Configuration](./configuration.md).
52
+ 2. **Built-in test-path skips** - rows marked `source: "built-in"` (numbered
53
+ from `0` among themselves), one per file and rule skipped because security
54
+ and sensitive-data rules skip test, fixture, and example paths. Text output
55
+ labels them `builtInTestPath[<path>]`.
56
+ 3. **Inline tool directives and duplicate merges** - rows continuing that
57
+ numbering with `source: "inline"` or `source: "duplicate"`:
58
+ - Supported inline comments on the reported line or alone on the line above
59
+ suppress the matching gruff finding: ESLint `no-eval` and `no-new-func`
60
+ (or a bare per-line ESLint disable covering both); Biome
61
+ `lint/security/noGlobalEval`, `lint/correctness/noUnusedImports`, or a
62
+ parent group such as `lint/security`; and zizmor `ignore[unpinned-uses]`
63
+ and `ignore[dangerous-triggers]`. Type-checker comments (`@ts-expect-error`)
64
+ and file-wide directives are not honoured.
65
+ - An `eval` call flagged by both `security.eval-call` and
66
+ `security.unsafe-deserialization` reports once under `security.eval-call`
67
+ and records the merged duplicate as `source: "duplicate"`.
68
+ - Text output prints `Suppressed findings: N via ...` with `inline[<path>]`
69
+ and `duplicate[<path>]` labels, and SARIF keeps each removed finding as a
70
+ suppressed result (`"suppressions": [{"kind": "inSource", "justification": <reason>}]`).
71
+
72
+ `paths.details` lists every excluded path with a canonical `reason` and its
73
+ `source` (`config`, `gitignore`, or `default`). Only `config` entries include the
74
+ matching `pattern`. `paths.ignoredPaths` is the ordered path projection of those
75
+ detail rows.
76
+
77
+ ### Notes and the deep-scan budget
78
+
79
+ Notes explain scan-surface limits without changing the exit code. They sit at
80
+ `extensions.ts.topLevel.notes`, print in a `Notes:` block in text output, and are
81
+ left out of JSON when there are none:
82
+
83
+ - `no-analysable-files` - a requested path existed but contributed no supported
84
+ files, usually because ignore rules excluded everything under it.
85
+ - `non-text-file` - a file contained invalid UTF-8 or NUL bytes, so it was
86
+ skipped before parsing.
87
+
88
+ `bounded-deep-scan` is a non-fatal diagnostic rather than a note: a script file
89
+ went over the deep-scan budget of 20,000 lines or 2,000,000 UTF-8 bytes,
90
+ whichever comes first. The file still counts as analysed and text-level rules
91
+ still run, but deep TypeScript passes, parse diagnostics, and project-graph
92
+ retention are skipped for it. `--deep-scan-budget <lines:bytes|off>` changes or
93
+ turns off the budget. A non-fatal diagnostic like this leaves the exit code
94
+ alone; a fatal one exits `2`.
95
+
96
+ Score math clusters correlated `complexity.cyclomatic` and `size.function-length`
97
+ findings once per function symbol. The `findings` array still lists each finding;
98
+ only pillar penalties and offender scores are deduplicated.
32
99
 
33
100
  ## HTML
34
101
 
35
- Use `html` for archived human review or dashboard scan output:
102
+ Use `html` for archived human review or dashboard output:
36
103
 
37
104
  ```sh
38
- ./bin/gruff-ts report src --format=html --output gruff-ts.html
105
+ npx gruff-ts report src --format=html --output gruff-ts.html
39
106
  ```
40
107
 
41
108
  ## Markdown
42
109
 
43
- Use `markdown` for pull request comments and release notes.
110
+ Use `markdown` for pull request comments and summaries.
44
111
 
45
112
  ## GitHub
46
113
 
@@ -48,28 +115,36 @@ Use `github` inside GitHub Actions to emit workflow annotations.
48
115
 
49
116
  ## Hotspot
50
117
 
51
- Use `hotspot` for compact score and offender analysis.
118
+ Use `hotspot` for the compact score and file-offender list. Its `diagnostics`
119
+ array carries the same scan diagnostics as `json`, such as a
120
+ `bounded-deep-scan` notice.
52
121
 
53
122
  ## SARIF
54
123
 
55
124
  Use `sarif` for GitHub code scanning or other SARIF consumers:
56
125
 
57
126
  ```sh
58
- ./bin/gruff-ts analyse src --format=sarif --fail-on=none > gruff-ts.sarif
127
+ npx gruff-ts analyse src --format=sarif --fail-on=none > gruff-ts.sarif
59
128
  ```
60
129
 
130
+ SARIF stays on version 2.1.0, and `runs[0].properties.gruffSchemaVersion`
131
+ matches `gruff.analysis.v3`.
132
+
61
133
  ## Summary
62
134
 
63
- `summary` has its own compact text/JSON contract:
135
+ JSON summary is the analysis v3 envelope with only the top-level `findings`
136
+ array removed and `schemaVersion` set to `gruff.summary.v3`:
64
137
 
65
138
  ```sh
66
- ./bin/gruff-ts summary src --format=json --top=5 --fail-on=none
139
+ npx gruff-ts summary src --format=json --fail-on=none
67
140
  ```
68
141
 
69
- TypeScript keeps the existing `summary` analysis flags such as `--diff`,
70
- `--baseline`, and `--generate-baseline` as extensions.
142
+ The same inputs and flags produce identical `run`, counts, scores, diagnostics,
143
+ paths, suppressions, baseline, diff, and extensions fields. `--top` affects text
144
+ output only. Analysis flags such as `--diff`, `--baseline`, and
145
+ `--generate-baseline` work on `summary` as well.
71
146
 
72
147
  ## Exit Codes
73
148
 
74
- `analyse` exits `1` when at least one finding meets `--fail-on`. Use
149
+ `analyse` exits `1` when at least one finding meets `--fail-on`. Pass
75
150
  `--fail-on none` for report-only jobs.
@@ -12,10 +12,10 @@ Used as a hook on an agent's output, gruff-ts is a forcing function, not advice.
12
12
 
13
13
  - **Verifiable.** The change can be checked by reading, not by re-deriving what the agent was thinking. The complexity, size, naming, and documentation pillars push toward code whose intent is visible on its face.
14
14
  - **Secure where the eye slips.** Human review reliably misses a known set of unsafe patterns - disabled TLS verification, `eval` and dynamic `Function` construction, injection-shaped string building, committed secrets. The security and sensitive-data pillars catch those mechanically so the reviewer does not have to.
15
- - **Honestly tested.** A test suite should raise confidence, not just coverage. The test-quality pillar flags low-signal ceremony - mock-only, snapshot-only, assertion-free, and tautological tests - so an agent cannot satisfy a "write tests" instruction with padding.
15
+ - **Honestly tested.** A test suite should raise confidence, not just coverage. The test-quality pillar flags tautological assertions, shape-only checks that duplicate TypeScript, unused mocks, unlabelled assertion loops, global state mutation, and copy-pasted test bodies so an agent cannot satisfy a "write tests" instruction with padding.
16
16
 
17
17
  ## Why documentation is mandatory, even on a private one-liner
18
18
 
19
19
  Coding agents routinely produce code that superficially works while misunderstanding the requirement. The implementation can be plausible and still solve the wrong problem, and that failure is invisible to a reviewer reading only the code.
20
20
 
21
- Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives the reviewer something to check the implementation against. The doc comment is a second, independent statement of what the code is meant to do, and a mismatch between that prose and the code is itself a signal that the change needs a deeper look. That is worth the friction even on a one-line private helper, because the cost of a confidently-wrong agent change is paid by the human who trusted it.
21
+ Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives the reviewer something to check the implementation against. The doc comment is a second, independent statement of what the code is meant to do, and a mismatch between that prose and the code is itself a signal that the change needs a deeper look. That is worth the friction even on a one-line private helper, because the cost of a confidently wrong agent change is paid by the human who trusted it.