@boyingliu01/xp-gate 0.38.34 → 0.38.35

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.
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-19T10:29:21.650Z",
5
+ "checked_at": "2026-11-19T12:48:44.088Z",
6
6
  "source": "network"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.38.34",
3
+ "version": "0.38.35",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.38.34",
3
+ "version": "0.38.35",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.38.34",
3
+ "version": "0.38.35",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -24,7 +24,7 @@ describe('analyzer.ts - Rule Orchestration Engine', () => {
24
24
  extractClasses: vi.fn().mockReturnValue([]),
25
25
  extractExports: vi.fn().mockReturnValue([]),
26
26
  countLines: vi.fn().mockReturnValue(100),
27
- getDuplication: vi.fn().mockReturnValue({ percentage: 0, blocks: [] })
27
+ getDuplication: vi.fn().mockReturnValue({ percentage: 0, blocks: [] }), declaresRuleCoverage: true
28
28
  };
29
29
 
30
30
  // Mock rule that detects violations
@@ -134,7 +134,7 @@ function adapterReportingLines(totalLines: number): Adapter {
134
134
  extractClasses: () => [],
135
135
  extractExports: () => [],
136
136
  countLines: () => totalLines,
137
- getDuplication: () => ({ percentage: 0, blocks: [] }),
137
+ getDuplication: () => ({ percentage: 0, blocks: [] }), declaresRuleCoverage: true
138
138
  };
139
139
  }
140
140
 
@@ -8,42 +8,89 @@ import { describe, it, expect } from 'vitest';
8
8
  import { formatConsole, formatJSON, formatSARIF, formatSummary } from '../reporter';
9
9
  import { AnalysisResult, Violation } from '../analyzer';
10
10
 
11
- describe('reporter.ts - Output Formatting', () => {
12
- const sampleViolation: Violation = {
13
- file: 'src/test.ts',
14
- line: 10,
15
- column: 5,
16
- ruleId: 'clean-code.long-function',
17
- message: 'Function "processData" is too long: 65 lines (maximum: 50)',
18
- severity: 'warning'
11
+ /**
12
+ * Build an AnalysisResult summary.
13
+ *
14
+ * Extracted because these fixtures were written out in full 25 times, which the
15
+ * clean-code.code-duplication rule scored at 44.2% (threshold 15%) and the Boy
16
+ * Scout gate then blocked. The counts are positional rather than a params object
17
+ * because every call site already reads as one line of counts, and a named-field
18
+ * object per fixture would be longer than the literal it replaces.
19
+ *
20
+ * `unanalysedLanguages` defaults to empty: no fixture here exercises the
21
+ * not-analysed notice, and tests that do set it explicitly via the options and
22
+ * assert on it there.
23
+ */
24
+ function summaryOf(
25
+ totalViolations: number,
26
+ errorCount: number,
27
+ warningCount: number,
28
+ infoCount: number,
29
+ filesChecked: number,
30
+ rulesRun: number,
31
+ unanalysedLanguages: string[] = []
32
+ ): AnalysisResult['summary'] {
33
+ return {
34
+ totalViolations,
35
+ errorCount,
36
+ warningCount,
37
+ infoCount,
38
+ filesChecked,
39
+ rulesRun,
40
+ unanalysedLanguages,
19
41
  };
42
+ }
43
+
44
+ /**
45
+ * The empty `fileResults` / `ruleResults` / `errors` set plus a duration.
46
+ *
47
+ * These lines appeared verbatim in 14 fixtures -- the remainder of the
48
+ * duplication the `summaryOf` extraction above did not reach (`errors: []` alone
49
+ * accounted for 21 of the repeated 3-line windows). Kept separate from summaryOf
50
+ * because the two vary independently: several tests supply real ruleResults, and
51
+ * one supplies a NaN errorCount.
52
+ */
53
+ function emptyResults(executionTimeMs: number): Pick<
54
+ AnalysisResult,
55
+ 'fileResults' | 'ruleResults' | 'executionTimeMs' | 'errors'
56
+ > {
57
+ return { fileResults: {}, ruleResults: {}, executionTimeMs, errors: [] };
58
+ }
59
+
60
+ /**
61
+ * Build a Violation.
62
+ *
63
+ * These were written out as five-to-six line object literals 17 times, which the
64
+ * clean-code.code-duplication rule scored well above its 15% threshold and the
65
+ * Boy Scout gate blocked. Named fields would be longer than the literal they
66
+ * replace and would bury the one thing each fixture is really saying -- which
67
+ * file, which rule, which message -- so the two axes stay positional here.
68
+ *
69
+ * `column` is optional because only the first fixture asserts on it.
70
+ */
71
+ function violation(
72
+ file: string,
73
+ line: number,
74
+ ruleId: string,
75
+ message: string,
76
+ severity: Violation['severity'],
77
+ column?: number
78
+ ): Violation {
79
+ return column === undefined
80
+ ? { file, line, ruleId, message, severity }
81
+ : { file, line, column, ruleId, message, severity };
82
+ }
83
+
84
+ describe('reporter.ts - Output Formatting', () => {
85
+ const sampleViolation: Violation = violation("src/test.ts", 10, "clean-code.long-function", "Function \"processData\" is too long: 65 lines (maximum: 50)", "warning", 5);
20
86
 
21
87
  const sampleResult: AnalysisResult = {
22
88
  violations: [
23
89
  sampleViolation,
24
- {
25
- file: 'src/utils.ts',
26
- line: 1,
27
- ruleId: 'clean-code.large-file',
28
- message: 'File is too large: 600 lines (maximum: 500)',
29
- severity: 'warning'
30
- },
31
- {
32
- file: 'src/api.ts',
33
- line: 20,
34
- ruleId: 'solid.dip',
35
- message: 'Direct instantiation detected: new UserRepository()',
36
- severity: 'warning'
37
- }
90
+ violation("src/utils.ts", 1, "clean-code.large-file", "File is too large: 600 lines (maximum: 500)", "warning"),
91
+ violation("src/api.ts", 20, "solid.dip", "Direct instantiation detected: new UserRepository()", "warning")
38
92
  ],
39
- summary: {
40
- totalViolations: 3,
41
- errorCount: 0,
42
- warningCount: 3,
43
- infoCount: 0,
44
- filesChecked: 3,
45
- rulesRun: 3
46
- },
93
+ summary: summaryOf(3, 0, 3, 0, 3, 3),
47
94
  fileResults: {
48
95
  'src/test.ts': { violations: [sampleViolation], ruleIds: ['clean-code.long-function'] }
49
96
  },
@@ -89,18 +136,8 @@ describe('reporter.ts - Output Formatting', () => {
89
136
  it('should handle empty violations', () => {
90
137
  const emptyResult: AnalysisResult = {
91
138
  violations: [],
92
- summary: {
93
- totalViolations: 0,
94
- errorCount: 0,
95
- warningCount: 0,
96
- infoCount: 0,
97
- filesChecked: 5,
98
- rulesRun: 3
99
- },
100
- fileResults: {},
101
- ruleResults: {},
102
- executionTimeMs: 50,
103
- errors: []
139
+ summary: summaryOf(0, 0, 0, 0, 5, 3),
140
+ ...emptyResults(50),
104
141
  };
105
142
 
106
143
  const output = formatConsole(emptyResult);
@@ -163,21 +200,63 @@ describe('reporter.ts - Output Formatting', () => {
163
200
  expect(output).toContain('FAIL');
164
201
  });
165
202
 
203
+ it('should not read a missing summary as FAIL (NaN must not decide the verdict)', () => {
204
+ // Round 3 of the Delphi review, three seats independently: `undefined + 0`
205
+ // is NaN, and `NaN === 0` is false, so an incomplete summary would make
206
+ // this report FAIL unconditionally -- the exact symptom the info fix
207
+ // removed, reintroduced through a different door. formatSummary is
208
+ // exported, so it cannot assume its caller honoured the type.
209
+ const noSummary = {
210
+ violations: [],
211
+ ...emptyResults(1),
212
+ } as unknown as AnalysisResult;
213
+
214
+ const output = formatSummary(noSummary);
215
+ expect(output).toContain('PASS');
216
+ expect(output).not.toContain('NaN');
217
+ });
218
+
219
+ it('should flag a malformed summary instead of silently treating it as clean', () => {
220
+ // Round 5, three seats independently: zeroing a non-numeric count stops the
221
+ // permanent-FAIL bug but also swallows an upstream defect -- a corrupted
222
+ // summary would read as "nothing to report". Keep the non-blocking verdict
223
+ // (crashing the reporter would be worse) but say so in the output.
224
+ const corrupted = {
225
+ violations: [],
226
+ summary: summaryOf(1, Number.NaN, 0, 0, 1, 1),
227
+ ...emptyResults(1),
228
+ } as unknown as AnalysisResult;
229
+
230
+ const output = formatSummary(corrupted);
231
+ expect(output).toMatch(/malformed|invalid|corrupt/i);
232
+ // The damaged field must be named, so a reader can tell WHICH count is
233
+ // untrustworthy. Echoing the raw value is the point of the diagnostic --
234
+ // only the verdict must never be decided by it.
235
+ expect(output).toContain('errorCount');
236
+ expect(output).toContain('PASS');
237
+ });
238
+
239
+ it('should show PASS when the only findings are info (info is log-only)', () => {
240
+ // AGENTS.md: info = "log only". An info finding is how a rule says "I
241
+ // could not judge this file" (the arch layout diagnostic), so treating it
242
+ // as a failure would block a commit for a blind spot rather than a defect.
243
+ const infoOnly: AnalysisResult = {
244
+ violations: [
245
+ violation("java/com/acme/UserController.java", 1, "arch.controller", "Skipped: no recognisable Java source root", "info")
246
+ ],
247
+ summary: summaryOf(1, 0, 0, 1, 1, 1),
248
+ ...emptyResults(1),
249
+ };
250
+ const output = formatSummary(infoOnly);
251
+ expect(output).toContain('PASS');
252
+ expect(output).not.toContain('FAIL');
253
+ });
254
+
166
255
  it('should show PASS when no violations', () => {
167
256
  const emptyResult: AnalysisResult = {
168
257
  violations: [],
169
- summary: {
170
- totalViolations: 0,
171
- errorCount: 0,
172
- warningCount: 0,
173
- infoCount: 0,
174
- filesChecked: 5,
175
- rulesRun: 3
176
- },
177
- fileResults: {},
178
- ruleResults: {},
179
- executionTimeMs: 50,
180
- errors: []
258
+ summary: summaryOf(0, 0, 0, 0, 5, 3),
259
+ ...emptyResults(50),
181
260
  };
182
261
 
183
262
  const output = formatSummary(emptyResult);
@@ -188,26 +267,10 @@ describe('reporter.ts - Output Formatting', () => {
188
267
  it('should show error count when severity has errors', () => {
189
268
  const errorResult: AnalysisResult = {
190
269
  violations: [
191
- {
192
- file: 'src/auth.ts',
193
- line: 5,
194
- ruleId: 'solid.srp',
195
- message: 'Class handles both auth and logging',
196
- severity: 'error'
197
- }
270
+ violation("src/auth.ts", 5, "solid.srp", "Class handles both auth and logging", "error")
198
271
  ],
199
- summary: {
200
- totalViolations: 1,
201
- errorCount: 1,
202
- warningCount: 0,
203
- infoCount: 0,
204
- filesChecked: 1,
205
- rulesRun: 1
206
- },
207
- fileResults: {},
208
- ruleResults: {},
209
- executionTimeMs: 30,
210
- errors: []
272
+ summary: summaryOf(1, 1, 0, 0, 1, 1),
273
+ ...emptyResults(30),
211
274
  };
212
275
 
213
276
  const output = formatSummary(errorResult);
@@ -221,14 +284,7 @@ describe('reporter.ts - Output Formatting', () => {
221
284
  it('should return valid SARIF JSON with version 2.1.0', () => {
222
285
  const result: AnalysisResult = {
223
286
  violations: [sampleViolation],
224
- summary: {
225
- totalViolations: 1,
226
- errorCount: 0,
227
- warningCount: 1,
228
- infoCount: 0,
229
- filesChecked: 1,
230
- rulesRun: 1
231
- },
287
+ summary: summaryOf(1, 0, 1, 0, 1, 1),
232
288
  fileResults: {},
233
289
  ruleResults: {
234
290
  'clean-code.long-function': { violationCount: 1, filesChecked: 1 }
@@ -247,14 +303,7 @@ describe('reporter.ts - Output Formatting', () => {
247
303
  it('should include runs array with tool driver info', () => {
248
304
  const result: AnalysisResult = {
249
305
  violations: [sampleViolation],
250
- summary: {
251
- totalViolations: 1,
252
- errorCount: 0,
253
- warningCount: 1,
254
- infoCount: 0,
255
- filesChecked: 3,
256
- rulesRun: 2
257
- },
306
+ summary: summaryOf(1, 0, 1, 0, 3, 2),
258
307
  fileResults: {},
259
308
  ruleResults: {
260
309
  'clean-code.long-function': { violationCount: 1, filesChecked: 3 }
@@ -275,37 +324,11 @@ describe('reporter.ts - Output Formatting', () => {
275
324
  it('should map violations to SARIF results with correct levels', () => {
276
325
  const result: AnalysisResult = {
277
326
  violations: [
278
- {
279
- file: 'src/auth.ts',
280
- line: 5,
281
- column: 10,
282
- ruleId: 'solid.srp',
283
- message: 'Multiple responsibilities',
284
- severity: 'error'
285
- },
286
- {
287
- file: 'src/utils.ts',
288
- line: 20,
289
- ruleId: 'clean-code.long-function',
290
- message: 'Function too long',
291
- severity: 'warning'
292
- },
293
- {
294
- file: 'src/config.ts',
295
- line: 3,
296
- ruleId: 'clean-code.magic-numbers',
297
- message: 'Magic number 42',
298
- severity: 'info'
299
- }
327
+ violation("src/auth.ts", 5, "solid.srp", "Multiple responsibilities", "error", 10),
328
+ violation("src/utils.ts", 20, "clean-code.long-function", "Function too long", "warning"),
329
+ violation("src/config.ts", 3, "clean-code.magic-numbers", "Magic number 42", "info")
300
330
  ],
301
- summary: {
302
- totalViolations: 3,
303
- errorCount: 1,
304
- warningCount: 1,
305
- infoCount: 1,
306
- filesChecked: 3,
307
- rulesRun: 3
308
- },
331
+ summary: summaryOf(3, 1, 1, 1, 3, 3),
309
332
  fileResults: {},
310
333
  ruleResults: {
311
334
  'solid.srp': { violationCount: 1, filesChecked: 1 },
@@ -329,23 +352,9 @@ describe('reporter.ts - Output Formatting', () => {
329
352
  it('should include file, line, and column in result locations', () => {
330
353
  const result: AnalysisResult = {
331
354
  violations: [
332
- {
333
- file: 'src/api.ts',
334
- line: 42,
335
- column: 15,
336
- ruleId: 'clean-code.deep-nesting',
337
- message: 'Nesting depth 6 exceeds threshold 4',
338
- severity: 'warning'
339
- }
355
+ violation("src/api.ts", 42, "clean-code.deep-nesting", "Nesting depth 6 exceeds threshold 4", "warning", 15)
340
356
  ],
341
- summary: {
342
- totalViolations: 1,
343
- errorCount: 0,
344
- warningCount: 1,
345
- infoCount: 0,
346
- filesChecked: 1,
347
- rulesRun: 1
348
- },
357
+ summary: summaryOf(1, 0, 1, 0, 1, 1),
349
358
  fileResults: {},
350
359
  ruleResults: {
351
360
  'clean-code.deep-nesting': { violationCount: 1, filesChecked: 1 }
@@ -366,22 +375,9 @@ describe('reporter.ts - Output Formatting', () => {
366
375
  it('should default column to 1 when violation has no column', () => {
367
376
  const result: AnalysisResult = {
368
377
  violations: [
369
- {
370
- file: 'src/big.ts',
371
- line: 500,
372
- ruleId: 'clean-code.large-file',
373
- message: 'File too large',
374
- severity: 'warning'
375
- }
378
+ violation("src/big.ts", 500, "clean-code.large-file", "File too large", "warning")
376
379
  ],
377
- summary: {
378
- totalViolations: 1,
379
- errorCount: 0,
380
- warningCount: 1,
381
- infoCount: 0,
382
- filesChecked: 1,
383
- rulesRun: 1
384
- },
380
+ summary: summaryOf(1, 0, 1, 0, 1, 1),
385
381
  fileResults: {},
386
382
  ruleResults: {
387
383
  'clean-code.large-file': { violationCount: 1, filesChecked: 1 }
@@ -400,14 +396,7 @@ describe('reporter.ts - Output Formatting', () => {
400
396
  it('should include ruleDescriptors for all rules in ruleResults', () => {
401
397
  const result: AnalysisResult = {
402
398
  violations: [sampleViolation],
403
- summary: {
404
- totalViolations: 1,
405
- errorCount: 0,
406
- warningCount: 1,
407
- infoCount: 0,
408
- filesChecked: 2,
409
- rulesRun: 2
410
- },
399
+ summary: summaryOf(1, 0, 1, 0, 2, 2),
411
400
  fileResults: {},
412
401
  ruleResults: {
413
402
  'clean-code.long-function': { violationCount: 1, filesChecked: 2 },
@@ -431,14 +420,7 @@ describe('reporter.ts - Output Formatting', () => {
431
420
  it('should include execution properties (filesChecked, rulesRun, executionTimeMs)', () => {
432
421
  const result: AnalysisResult = {
433
422
  violations: [],
434
- summary: {
435
- totalViolations: 0,
436
- errorCount: 0,
437
- warningCount: 0,
438
- infoCount: 0,
439
- filesChecked: 10,
440
- rulesRun: 5
441
- },
423
+ summary: summaryOf(0, 0, 0, 0, 10, 5),
442
424
  fileResults: {},
443
425
  ruleResults: {
444
426
  'clean-code.long-function': { violationCount: 0, filesChecked: 10 }
@@ -459,14 +441,7 @@ describe('reporter.ts - Output Formatting', () => {
459
441
  it('should return empty results array when no violations', () => {
460
442
  const result: AnalysisResult = {
461
443
  violations: [],
462
- summary: {
463
- totalViolations: 0,
464
- errorCount: 0,
465
- warningCount: 0,
466
- infoCount: 0,
467
- filesChecked: 5,
468
- rulesRun: 3
469
- },
444
+ summary: summaryOf(0, 0, 0, 0, 5, 3),
470
445
  fileResults: {},
471
446
  ruleResults: {
472
447
  'clean-code.long-function': { violationCount: 0, filesChecked: 5 }
@@ -484,23 +459,9 @@ describe('reporter.ts - Output Formatting', () => {
484
459
  it('should map DIP violation to error level when violation severity is error', () => {
485
460
  const result: AnalysisResult = {
486
461
  violations: [
487
- {
488
- file: 'src/service.ts',
489
- line: 8,
490
- column: 1,
491
- ruleId: 'solid.dip',
492
- message: 'Direct instantiation detected',
493
- severity: 'error'
494
- }
462
+ violation("src/service.ts", 8, "solid.dip", "Direct instantiation detected", "error", 1)
495
463
  ],
496
- summary: {
497
- totalViolations: 1,
498
- errorCount: 1,
499
- warningCount: 0,
500
- infoCount: 0,
501
- filesChecked: 1,
502
- rulesRun: 1
503
- },
464
+ summary: summaryOf(1, 1, 0, 0, 1, 1),
504
465
  fileResults: {},
505
466
  ruleResults: {
506
467
  'solid.dip': { violationCount: 1, filesChecked: 1 }
@@ -518,14 +479,7 @@ describe('reporter.ts - Output Formatting', () => {
518
479
  it('should include ruleDescriptors with defaultConfiguration levels', () => {
519
480
  const result: AnalysisResult = {
520
481
  violations: [],
521
- summary: {
522
- totalViolations: 0,
523
- errorCount: 0,
524
- warningCount: 0,
525
- infoCount: 0,
526
- filesChecked: 1,
527
- rulesRun: 3
528
- },
482
+ summary: summaryOf(0, 0, 0, 0, 1, 3),
529
483
  fileResults: {},
530
484
  ruleResults: {
531
485
  'solid.srp': { violationCount: 0, filesChecked: 1 },
@@ -554,27 +508,10 @@ describe('reporter.ts - Output Formatting', () => {
554
508
  it('should show error severity with ✗ icon', () => {
555
509
  const errorResult: AnalysisResult = {
556
510
  violations: [
557
- {
558
- file: 'src/auth.ts',
559
- line: 5,
560
- column: 1,
561
- ruleId: 'solid.srp',
562
- message: 'Multiple responsibilities',
563
- severity: 'error'
564
- }
511
+ violation("src/auth.ts", 5, "solid.srp", "Multiple responsibilities", "error", 1)
565
512
  ],
566
- summary: {
567
- totalViolations: 1,
568
- errorCount: 1,
569
- warningCount: 0,
570
- infoCount: 0,
571
- filesChecked: 1,
572
- rulesRun: 1
573
- },
574
- fileResults: {},
575
- ruleResults: {},
576
- executionTimeMs: 30,
577
- errors: []
513
+ summary: summaryOf(1, 1, 0, 0, 1, 1),
514
+ ...emptyResults(30),
578
515
  };
579
516
 
580
517
  const output = formatConsole(errorResult);
@@ -586,27 +523,10 @@ describe('reporter.ts - Output Formatting', () => {
586
523
  it('should show info severity with ℹ icon', () => {
587
524
  const infoResult: AnalysisResult = {
588
525
  violations: [
589
- {
590
- file: 'src/config.ts',
591
- line: 3,
592
- column: 10,
593
- ruleId: 'clean-code.magic-numbers',
594
- message: 'Magic number 42',
595
- severity: 'info'
596
- }
526
+ violation("src/config.ts", 3, "clean-code.magic-numbers", "Magic number 42", "info", 10)
597
527
  ],
598
- summary: {
599
- totalViolations: 1,
600
- errorCount: 0,
601
- warningCount: 0,
602
- infoCount: 1,
603
- filesChecked: 1,
604
- rulesRun: 1
605
- },
606
- fileResults: {},
607
- ruleResults: {},
608
- executionTimeMs: 20,
609
- errors: []
528
+ summary: summaryOf(1, 0, 0, 1, 1, 1),
529
+ ...emptyResults(20),
610
530
  };
611
531
 
612
532
  const output = formatConsole(infoResult);
@@ -618,26 +538,10 @@ describe('reporter.ts - Output Formatting', () => {
618
538
  it('should handle violations without column number', () => {
619
539
  const noColumnResult: AnalysisResult = {
620
540
  violations: [
621
- {
622
- file: 'src/big.ts',
623
- line: 600,
624
- ruleId: 'clean-code.large-file',
625
- message: 'File is too large: 600 lines (maximum: 500)',
626
- severity: 'warning'
627
- }
541
+ violation("src/big.ts", 600, "clean-code.large-file", "File is too large: 600 lines (maximum: 500)", "warning")
628
542
  ],
629
- summary: {
630
- totalViolations: 1,
631
- errorCount: 0,
632
- warningCount: 1,
633
- infoCount: 0,
634
- filesChecked: 1,
635
- rulesRun: 1
636
- },
637
- fileResults: {},
638
- ruleResults: {},
639
- executionTimeMs: 25,
640
- errors: []
543
+ summary: summaryOf(1, 0, 1, 0, 1, 1),
544
+ ...emptyResults(25),
641
545
  };
642
546
 
643
547
  const output = formatConsole(noColumnResult);
@@ -649,26 +553,10 @@ describe('reporter.ts - Output Formatting', () => {
649
553
  it('should include analysis errors only when violations exist', () => {
650
554
  const resultWithErrors: AnalysisResult = {
651
555
  violations: [
652
- {
653
- file: 'src/test.ts',
654
- line: 5,
655
- column: 1,
656
- ruleId: 'clean-code.long-function',
657
- message: 'Function too long',
658
- severity: 'warning'
659
- }
556
+ violation("src/test.ts", 5, "clean-code.long-function", "Function too long", "warning", 1)
660
557
  ],
661
- summary: {
662
- totalViolations: 1,
663
- errorCount: 0,
664
- warningCount: 1,
665
- infoCount: 0,
666
- filesChecked: 2,
667
- rulesRun: 1
668
- },
669
- fileResults: {},
670
- ruleResults: {},
671
- executionTimeMs: 50,
558
+ summary: summaryOf(1, 0, 1, 0, 2, 1),
559
+ ...emptyResults(50),
672
560
  errors: [
673
561
  'Rule clean-code.long-function failed on src/corrupt.ts: Parse error',
674
562
  'Rule solid.srp failed on src/broken.ts: Timeout'
@@ -685,18 +573,8 @@ describe('reporter.ts - Output Formatting', () => {
685
573
  it('should not show analysis errors section when errors array is empty', () => {
686
574
  const emptyResult: AnalysisResult = {
687
575
  violations: [],
688
- summary: {
689
- totalViolations: 0,
690
- errorCount: 0,
691
- warningCount: 0,
692
- infoCount: 0,
693
- filesChecked: 5,
694
- rulesRun: 3
695
- },
696
- fileResults: {},
697
- ruleResults: {},
698
- executionTimeMs: 50,
699
- errors: []
576
+ summary: summaryOf(0, 0, 0, 0, 5, 3),
577
+ ...emptyResults(50),
700
578
  };
701
579
 
702
580
  const output = formatConsole(emptyResult);
@@ -707,18 +585,8 @@ describe('reporter.ts - Output Formatting', () => {
707
585
  it('should show files checked in empty violations output', () => {
708
586
  const emptyResult: AnalysisResult = {
709
587
  violations: [],
710
- summary: {
711
- totalViolations: 0,
712
- errorCount: 0,
713
- warningCount: 0,
714
- infoCount: 0,
715
- filesChecked: 15,
716
- rulesRun: 8
717
- },
718
- fileResults: {},
719
- ruleResults: {},
720
- executionTimeMs: 75,
721
- errors: []
588
+ summary: summaryOf(0, 0, 0, 0, 15, 8),
589
+ ...emptyResults(75),
722
590
  };
723
591
 
724
592
  const output = formatConsole(emptyResult);
@@ -731,34 +599,11 @@ describe('reporter.ts - Output Formatting', () => {
731
599
  it('should include summary section with violation details', () => {
732
600
  const mixedResult: AnalysisResult = {
733
601
  violations: [
734
- {
735
- file: 'src/a.ts',
736
- line: 5,
737
- column: 1,
738
- ruleId: 'solid.srp',
739
- message: 'SRP violation',
740
- severity: 'error'
741
- },
742
- {
743
- file: 'src/b.ts',
744
- line: 10,
745
- ruleId: 'clean-code.long-function',
746
- message: 'Too long',
747
- severity: 'warning'
748
- }
602
+ violation("src/a.ts", 5, "solid.srp", "SRP violation", "error", 1),
603
+ violation("src/b.ts", 10, "clean-code.long-function", "Too long", "warning")
749
604
  ],
750
- summary: {
751
- totalViolations: 2,
752
- errorCount: 1,
753
- warningCount: 1,
754
- infoCount: 0,
755
- filesChecked: 2,
756
- rulesRun: 2
757
- },
758
- fileResults: {},
759
- ruleResults: {},
760
- executionTimeMs: 60,
761
- errors: []
605
+ summary: summaryOf(2, 1, 1, 0, 2, 2),
606
+ ...emptyResults(60),
762
607
  };
763
608
 
764
609
  const output = formatConsole(mixedResult);
@@ -775,18 +620,8 @@ describe('reporter.ts - Output Formatting', () => {
775
620
  it('should include empty arrays for no violations', () => {
776
621
  const emptyResult: AnalysisResult = {
777
622
  violations: [],
778
- summary: {
779
- totalViolations: 0,
780
- errorCount: 0,
781
- warningCount: 0,
782
- infoCount: 0,
783
- filesChecked: 5,
784
- rulesRun: 3
785
- },
786
- fileResults: {},
787
- ruleResults: {},
788
- executionTimeMs: 30,
789
- errors: []
623
+ summary: summaryOf(0, 0, 0, 0, 5, 3),
624
+ ...emptyResults(30),
790
625
  };
791
626
 
792
627
  const output = formatJSON(emptyResult);
@@ -800,14 +635,7 @@ describe('reporter.ts - Output Formatting', () => {
800
635
  it('should include all fields: violations, summary, fileResults, ruleResults, executionTimeMs, errors', () => {
801
636
  const result: AnalysisResult = {
802
637
  violations: [sampleViolation],
803
- summary: {
804
- totalViolations: 1,
805
- errorCount: 0,
806
- warningCount: 1,
807
- infoCount: 0,
808
- filesChecked: 3,
809
- rulesRun: 2
810
- },
638
+ summary: summaryOf(1, 0, 1, 0, 3, 2),
811
639
  fileResults: {
812
640
  'src/test.ts': { violations: [sampleViolation], ruleIds: ['clean-code.long-function'] }
813
641
  },
@@ -92,7 +92,7 @@ describe('types.ts - Core Interfaces', () => {
92
92
  extractClasses: () => [],
93
93
  extractExports: () => [],
94
94
  countLines: () => 0,
95
- getDuplication: () => ({ percentage: 0, blocks: [] }),
95
+ getDuplication: () => ({ percentage: 0, blocks: [] }), declaresRuleCoverage: true,
96
96
  };
97
97
 
98
98
  expect(adapter.detectLanguage).toBeDefined();
@@ -72,6 +72,32 @@ export abstract class BaseAdapter implements Adapter {
72
72
  return measureDuplication(this.fileContent);
73
73
  }
74
74
 
75
+ /**
76
+ * Does this adapter really support the clean-code rules, or does it only make
77
+ * the language DETECTABLE?
78
+ *
79
+ * `false` is the SAFE default here, and the direction is worth stating plainly
80
+ * because it is the opposite of the usual instinct: `false` makes the gate say
81
+ * "this language was not analysed", which is a loss of claimed coverage, while
82
+ * `true` makes it say "clean", which is a claim about code nobody looked at.
83
+ * The first is a limitation; the second is a lie.
84
+ *
85
+ * So an adapter opts IN by overriding this to return `true` once it implements
86
+ * rules of its own. A new shallow adapter — detect the language, extract
87
+ * functions with a regex — inherits the honest answer without its author
88
+ * needing to know this member exists.
89
+ *
90
+ * Measured before this: a Go file with 6-level nesting produced
91
+ * `✓ No violations found / Files checked: 1 / Rules run: 21`, and all 21 rules
92
+ * ran against a file none of them can read. TypeScript with the same nesting is
93
+ * reported correctly, which is precisely why the gap survived — the gate looked
94
+ * like it worked.
95
+ * - a `readonly` property rather than a method, because the value is a static
96
+ * fact about the adapter and this class already sat at the 15-method
97
+ * God-Class threshold; a 16th method was a genuine warning, not a formality.
98
+ */
99
+ readonly declaresRuleCoverage: boolean = false;
100
+
75
101
  protected readFileContent(filePath: string): string {
76
102
  try {
77
103
  return readFileSync(filePath, 'utf-8');
@@ -81,6 +81,13 @@ function countMemberDeclarations(body: string): number {
81
81
  * problem (braces inside literals/comments) applies verbatim.
82
82
  */
83
83
  export class CSharpAdapter extends BaseAdapter implements Adapter {
84
+ /**
85
+ * This adapter implements rules of its own, so the gate may report its files
86
+ * as genuinely examined. Adapters that only make a language detectable leave
87
+ * this at the BaseAdapter default (`false`) and are reported as unanalysed.
88
+ */
89
+ readonly declaresRuleCoverage: boolean = true;
90
+
84
91
  detectLanguage(): string {
85
92
  const lower = this.filePath.toLowerCase();
86
93
  if (lower.endsWith('.cs') || lower.endsWith('.csx')) {
@@ -351,6 +351,13 @@ export const javaParse = {
351
351
  };
352
352
 
353
353
  export class JavaAdapter extends BaseAdapter implements Adapter {
354
+ /**
355
+ * This adapter implements rules of its own, so the gate may report its files
356
+ * as genuinely examined. Adapters that only make a language detectable leave
357
+ * this at the BaseAdapter default (`false`) and are reported as unanalysed.
358
+ */
359
+ readonly declaresRuleCoverage: boolean = true;
360
+
354
361
  detectLanguage(): string {
355
362
  const ext = this.filePath.toLowerCase();
356
363
  if (ext.endsWith('.java')) {
@@ -576,6 +576,13 @@ interface FunctionMetrics {
576
576
  }
577
577
 
578
578
  export class TypeScriptAdapter extends BaseAdapter implements Adapter {
579
+ /**
580
+ * This adapter implements rules of its own, so the gate may report its files
581
+ * as genuinely examined. Adapters that only make a language detectable leave
582
+ * this at the BaseAdapter default (`false`) and are reported as unanalysed.
583
+ */
584
+ readonly declaresRuleCoverage: boolean = true;
585
+
579
586
  detectLanguage(): string {
580
587
  const ext = this.filePath.toLowerCase();
581
588
  if (ext.endsWith('.ts') || ext.endsWith('.tsx')) {
@@ -35,6 +35,22 @@ export interface AnalysisSummary {
35
35
  infoCount: number;
36
36
  filesChecked: number;
37
37
  rulesRun: number;
38
+ /**
39
+ * Languages whose files were counted in `filesChecked` but which NO rule can
40
+ * actually examine — the adapter makes them detectable, not analysable.
41
+ *
42
+ * This exists because "no violations found" was being printed for files no
43
+ * rule can read. Measured: a Go file with 6-level nesting reported
44
+ * `✓ No violations found / Files checked: 1 / Rules run: 21`, while the same
45
+ * shape in TypeScript is caught. Without this field a reader cannot tell a
46
+ * clean file from an unexamined one, which is the defect family AGENTS.md
47
+ * names most often: "not checked" must never be indistinguishable from
48
+ * "passed".
49
+ *
50
+ * Empty means every file in the run was genuinely analysable — the output then
51
+ * claims exactly what it did.
52
+ */
53
+ unanalysedLanguages: string[];
38
54
  }
39
55
 
40
56
  export interface AnalysisResult {
@@ -100,10 +116,56 @@ function resolveAdapter(
100
116
  return adapterOrFactory;
101
117
  }
102
118
 
119
+ /**
120
+ * Record, once per language, that this adapter cannot actually examine its own
121
+ * files — it makes the language detectable, not analysable.
122
+ *
123
+ * Split out of analyze() so the bookkeeping does not raise that function's
124
+ * cyclomatic complexity. The gate's output then says which languages were not
125
+ * checked instead of printing "✓ No violations found" over them.
126
+ */
127
+ function recordUnanalysed(adapter: Adapter, into: string[]): void {
128
+ if (adapter.declaresRuleCoverage) return;
129
+ const lang = adapter.detectLanguage();
130
+ if (!into.includes(lang)) into.push(lang);
131
+ }
132
+
133
+ /**
134
+ * Run every enabled rule against one file, accumulating into the shared result
135
+ * maps.
136
+ *
137
+ * Split out of analyze() for the same reason recordUnanalysed is: keeping the
138
+ * per-file, per-rule loop inline pushed analyze past the clean-code.long-function
139
+ * limit (56 lines against a maximum of 50), and that is a real signal -- the outer
140
+ * function is about orchestration, this is about one file.
141
+ */
142
+ function runRulesOnFile(context: {
143
+ file: string;
144
+ adapter: Adapter;
145
+ rules: Rule[];
146
+ violations: Violation[];
147
+ fileResult: FileResult;
148
+ ruleResults: Record<string, RuleResult>;
149
+ errors: string[];
150
+ }): void {
151
+ for (const rule of context.rules) {
152
+ runRuleOnFile({
153
+ file: context.file,
154
+ rule,
155
+ adapter: context.adapter,
156
+ violations: context.violations,
157
+ fileResult: context.fileResult,
158
+ ruleResult: context.ruleResults[rule.id],
159
+ errors: context.errors,
160
+ });
161
+ }
162
+ }
163
+
103
164
  function computeSummary(
104
165
  violations: Violation[],
105
166
  fileResults: Record<string, FileResult>,
106
167
  rulesToRun: Rule[],
168
+ unanalysedLanguages: string[],
107
169
  ): AnalysisSummary {
108
170
  let errorCount = 0;
109
171
  let warningCount = 0;
@@ -120,6 +182,7 @@ function computeSummary(
120
182
  infoCount,
121
183
  filesChecked: Object.keys(fileResults).length,
122
184
  rulesRun: rulesToRun.length,
185
+ unanalysedLanguages,
123
186
  };
124
187
  }
125
188
 
@@ -248,27 +311,21 @@ export async function analyze(
248
311
  ruleResults[rule.id] = { violationCount: 0, filesChecked: 0 };
249
312
  }
250
313
 
314
+ // Languages an adapter merely makes DETECTABLE: counted in filesChecked, read by
315
+ // no rule. See recordUnanalysed for why this is collected separately.
316
+ const unanalysedLanguages: string[] = [];
317
+
251
318
  for (const file of files) {
252
319
  const adapter = resolveAdapterReporting(file, adapterOrFactory, errors);
253
320
  if (!adapter) continue;
254
321
 
322
+ recordUnanalysed(adapter, unanalysedLanguages);
255
323
  const fileResult: FileResult = { violations: [], ruleIds: [] };
256
324
  fileResults[file] = fileResult;
257
-
258
- for (const rule of rulesToRun) {
259
- runRuleOnFile({
260
- file,
261
- rule,
262
- adapter,
263
- violations,
264
- fileResult,
265
- ruleResult: ruleResults[rule.id],
266
- errors,
267
- });
268
- }
325
+ runRulesOnFile({ file, adapter, rules: rulesToRun, violations, fileResult, ruleResults, errors });
269
326
  }
270
327
 
271
- const summary = computeSummary(violations, fileResults, rulesToRun);
328
+ const summary = computeSummary(violations, fileResults, rulesToRun, unanalysedLanguages);
272
329
 
273
330
  return {
274
331
  violations,
@@ -98,7 +98,7 @@ function getRuleLevel(ruleId: string): string {
98
98
  }
99
99
 
100
100
  function formatEmptyResult(result: AnalysisResult, lines: string[]): string {
101
- lines.push('✓ No violations found');
101
+ lines.push(...emptyResultHeadline(result.summary.unanalysedLanguages));
102
102
  lines.push('');
103
103
  lines.push(`Files checked: ${result.summary.filesChecked}`);
104
104
  lines.push(`Rules run: ${result.summary.rulesRun}`);
@@ -106,6 +106,34 @@ function formatEmptyResult(result: AnalysisResult, lines: string[]): string {
106
106
  return lines.join('\n');
107
107
  }
108
108
 
109
+ /**
110
+ * The headline of an empty result, which must not claim more than the run did.
111
+ *
112
+ * When some files belong to languages no rule can read, "✓ No violations found"
113
+ * on its own reads as "examined and clean" for code nobody examined — measured
114
+ * before this existed: a Go file with 6-level nesting produced exactly that line
115
+ * beside "Files checked: 1".
116
+ *
117
+ * The count stays visible either way, because the file WAS read and its language
118
+ * WAS identified; what has to change is the implication that rules looked at it.
119
+ *
120
+ * Split out of formatEmptyResult so the branch does not raise that function's
121
+ * cyclomatic complexity: it is a formatting decision, not an additional path
122
+ * through the reporting.
123
+ */
124
+ function emptyResultHeadline(unanalysed: string[]): string[] {
125
+ if (unanalysed.length > 0) {
126
+ return [
127
+ '✓ No violations found in the files that were analysed',
128
+ '',
129
+ `⚠️ NOT ANALYSED: ${unanalysed.join(', ')} — an adapter exists (the language ` +
130
+ 'is detected and counted below) but no clean-code rule can read it. These ' +
131
+ 'files were not checked; their absence from the list above is not a pass.',
132
+ ];
133
+ }
134
+ return ['✓ No violations found'];
135
+ }
136
+
109
137
  function formatViolationLines(violation: Violation): string[] {
110
138
  const severityIcon = violation.severity === 'error' ? '✗' :
111
139
  violation.severity === 'warning' ? '⚠' : 'ℹ';
@@ -9,7 +9,7 @@ const mockAdapter = {
9
9
  extractClasses: () => [],
10
10
  extractExports: () => [],
11
11
  countLines: (_fileName: string) => 10, // Default to small file
12
- getDuplication: () => ({ percentage: 0, blocks: [] })
12
+ getDuplication: () => ({ percentage: 0, blocks: [] }), declaresRuleCoverage: true
13
13
  };
14
14
 
15
15
  describe('largeFileRule', () => {
@@ -78,4 +78,33 @@ export interface Adapter {
78
78
  * not default into silence.
79
79
  */
80
80
  getDuplication: () => DuplicationReport;
81
+ /**
82
+ * Can this adapter actually support the clean-code rules, or does it only make
83
+ * the language DETECTABLE?
84
+ *
85
+ * Per `src/principles/AGENTS.md` the two are not the same and the difference is
86
+ * deliberate: this engine covers languages it can parse meaningfully, while the
87
+ * shell adapters cover languages it can lint or test. An adapter with no
88
+ * TS-side rule support is not a bug — but reporting its files as "✓ No
89
+ * violations found" is, because that reads as "examined and clean".
90
+ *
91
+ * Measured before this member existed: a Go file with 6-level nesting produced
92
+ * `✓ No violations found / Files checked: 1 / Rules run: 21`. All 21 rules ran
93
+ * against a file none of them can read. The same content in TypeScript is
94
+ * reported correctly, which is what made it invisible.
95
+ *
96
+ * REQUIRED, for the same reason `getDuplication` is: an optional member plus an
97
+ * `undefined`-means-analysed branch would reproduce the defect it fixes.
98
+ *
99
+ * The default lives in `BaseAdapter` and must be the SAFE side. Safe here is the
100
+ * opposite of instinct: `false` makes the gate say "not analysed", which is a
101
+ * loss of claimed coverage; `true` would make it say "clean", which is a claim
102
+ * about code nobody read. An adapter that genuinely implements rules opts in.
103
+ *
104
+ * A boolean property rather than a method — the value is a static fact about the
105
+ * adapter, not something that varies per call, and `BaseAdapter` already sat at
106
+ * the 15-method God-Class threshold, so a 16th method was a real warning rather
107
+ * than a formality.
108
+ */
109
+ declaresRuleCoverage: boolean;
81
110
  }