@aiready/testability 0.6.22 → 0.6.23
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/.turbo/turbo-build.log +24 -23
- package/.turbo/turbo-test.log +20 -18
- package/coverage/analyzer.ts.html +54 -165
- package/coverage/clover.xml +38 -53
- package/coverage/coverage-final.json +3 -3
- package/coverage/index.html +30 -30
- package/coverage/provider.ts.html +29 -59
- package/coverage/scoring.ts.html +24 -135
- package/dist/chunk-CE46EON2.mjs +240 -0
- package/dist/chunk-CISO2RDG.mjs +198 -0
- package/dist/chunk-KYBNMI4K.mjs +237 -0
- package/dist/cli.js +33 -76
- package/dist/cli.mjs +9 -9
- package/dist/index.js +23 -66
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/__tests__/scoring.test.ts +31 -0
- package/src/analyzer.ts +25 -78
- package/src/cli.ts +8 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
DTS
|
|
20
|
-
DTS
|
|
21
|
-
DTS dist/
|
|
22
|
-
DTS dist/
|
|
23
|
-
DTS dist/
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @aiready/testability@0.6.23 build /Users/pengcao/projects/aiready/packages/testability
|
|
4
|
+
> tsup src/index.ts src/cli.ts --format cjs,esm --dts
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.1
|
|
9
|
+
[34mCLI[39m Target: es2020
|
|
10
|
+
[34mCJS[39m Build start
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m11.84 KB[39m
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m8.57 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 46ms
|
|
15
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m4.33 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.17 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/chunk-CISO2RDG.mjs [22m[32m6.30 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 48ms
|
|
19
|
+
DTS Build start
|
|
20
|
+
DTS ⚡️ Build success in 2214ms
|
|
21
|
+
DTS dist/cli.d.ts 20.00 B
|
|
22
|
+
DTS dist/index.d.ts 2.42 KB
|
|
23
|
+
DTS dist/cli.d.mts 20.00 B
|
|
24
|
+
DTS dist/index.d.mts 2.42 KB
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[32m✓[39m src/__tests__/
|
|
10
|
-
[32m✓[39m src/__tests__/
|
|
11
|
-
[32m✓[39m src/__tests__/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[2m
|
|
16
|
-
[2m
|
|
17
|
-
[2m
|
|
18
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @aiready/testability@0.6.22 test /Users/pengcao/projects/aiready/packages/testability
|
|
4
|
+
> vitest run
|
|
5
|
+
|
|
6
|
+
[?25l
|
|
7
|
+
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/Users/pengcao/projects/aiready/packages/testability[39m
|
|
8
|
+
|
|
9
|
+
[32m✓[39m src/__tests__/types.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 34[2mms[22m[39m
|
|
10
|
+
[32m✓[39m src/__tests__/scoring.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
11
|
+
[32m✓[39m src/__tests__/provider.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
12
|
+
[32m✓[39m src/__tests__/analyzer.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 2004[2mms[22m[39m
|
|
13
|
+
[33m[2m✓[22m[39m detects test frameworks in multiple languages [33m 1975[2mms[22m[39m
|
|
14
|
+
|
|
15
|
+
[2m Test Files [22m [1m[32m4 passed[39m[22m[90m (4)[39m
|
|
16
|
+
[2m Tests [22m [1m[32m17 passed[39m[22m[90m (17)[39m
|
|
17
|
+
[2m Start at [22m 01:34:00
|
|
18
|
+
[2m Duration [22m 3.85s[2m (transform 825ms, setup 0ms, import 3.62s, tests 2.05s, environment 0ms)[22m
|
|
19
|
+
|
|
20
|
+
[?25h
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">91.22% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>52/57</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">83.33% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>42
|
|
35
|
+
<span class='fraction'>35/42</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>6/6</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">94.33% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>50/53</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -293,44 +293,7 @@
|
|
|
293
293
|
<a name='L228'></a><a href='#L228'>228</a>
|
|
294
294
|
<a name='L229'></a><a href='#L229'>229</a>
|
|
295
295
|
<a name='L230'></a><a href='#L230'>230</a>
|
|
296
|
-
<a name='L231'></a><a href='#L231'>231</a>
|
|
297
|
-
<a name='L232'></a><a href='#L232'>232</a>
|
|
298
|
-
<a name='L233'></a><a href='#L233'>233</a>
|
|
299
|
-
<a name='L234'></a><a href='#L234'>234</a>
|
|
300
|
-
<a name='L235'></a><a href='#L235'>235</a>
|
|
301
|
-
<a name='L236'></a><a href='#L236'>236</a>
|
|
302
|
-
<a name='L237'></a><a href='#L237'>237</a>
|
|
303
|
-
<a name='L238'></a><a href='#L238'>238</a>
|
|
304
|
-
<a name='L239'></a><a href='#L239'>239</a>
|
|
305
|
-
<a name='L240'></a><a href='#L240'>240</a>
|
|
306
|
-
<a name='L241'></a><a href='#L241'>241</a>
|
|
307
|
-
<a name='L242'></a><a href='#L242'>242</a>
|
|
308
|
-
<a name='L243'></a><a href='#L243'>243</a>
|
|
309
|
-
<a name='L244'></a><a href='#L244'>244</a>
|
|
310
|
-
<a name='L245'></a><a href='#L245'>245</a>
|
|
311
|
-
<a name='L246'></a><a href='#L246'>246</a>
|
|
312
|
-
<a name='L247'></a><a href='#L247'>247</a>
|
|
313
|
-
<a name='L248'></a><a href='#L248'>248</a>
|
|
314
|
-
<a name='L249'></a><a href='#L249'>249</a>
|
|
315
|
-
<a name='L250'></a><a href='#L250'>250</a>
|
|
316
|
-
<a name='L251'></a><a href='#L251'>251</a>
|
|
317
|
-
<a name='L252'></a><a href='#L252'>252</a>
|
|
318
|
-
<a name='L253'></a><a href='#L253'>253</a>
|
|
319
|
-
<a name='L254'></a><a href='#L254'>254</a>
|
|
320
|
-
<a name='L255'></a><a href='#L255'>255</a>
|
|
321
|
-
<a name='L256'></a><a href='#L256'>256</a>
|
|
322
|
-
<a name='L257'></a><a href='#L257'>257</a>
|
|
323
|
-
<a name='L258'></a><a href='#L258'>258</a>
|
|
324
|
-
<a name='L259'></a><a href='#L259'>259</a>
|
|
325
|
-
<a name='L260'></a><a href='#L260'>260</a>
|
|
326
|
-
<a name='L261'></a><a href='#L261'>261</a>
|
|
327
|
-
<a name='L262'></a><a href='#L262'>262</a>
|
|
328
|
-
<a name='L263'></a><a href='#L263'>263</a>
|
|
329
|
-
<a name='L264'></a><a href='#L264'>264</a>
|
|
330
|
-
<a name='L265'></a><a href='#L265'>265</a>
|
|
331
|
-
<a name='L266'></a><a href='#L266'>266</a>
|
|
332
|
-
<a name='L267'></a><a href='#L267'>267</a>
|
|
333
|
-
<a name='L268'></a><a href='#L268'>268</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
296
|
+
<a name='L231'></a><a href='#L231'>231</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
334
297
|
<span class="cline-any cline-neutral"> </span>
|
|
335
298
|
<span class="cline-any cline-neutral"> </span>
|
|
336
299
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -428,41 +391,19 @@
|
|
|
428
391
|
<span class="cline-any cline-neutral"> </span>
|
|
429
392
|
<span class="cline-any cline-neutral"> </span>
|
|
430
393
|
<span class="cline-any cline-neutral"> </span>
|
|
431
|
-
<span class="cline-any cline-yes">7x</span>
|
|
432
|
-
<span class="cline-any cline-neutral"> </span>
|
|
433
|
-
<span class="cline-any cline-neutral"> </span>
|
|
434
|
-
<span class="cline-any cline-neutral"> </span>
|
|
435
|
-
<span class="cline-any cline-neutral"> </span>
|
|
436
|
-
<span class="cline-any cline-neutral"> </span>
|
|
437
|
-
<span class="cline-any cline-neutral"> </span>
|
|
438
|
-
<span class="cline-any cline-neutral"> </span>
|
|
439
|
-
<span class="cline-any cline-neutral"> </span>
|
|
440
|
-
<span class="cline-any cline-neutral"> </span>
|
|
441
|
-
<span class="cline-any cline-neutral"> </span>
|
|
442
394
|
<span class="cline-any cline-neutral"> </span>
|
|
443
395
|
<span class="cline-any cline-yes">7x</span>
|
|
444
|
-
<span class="cline-any cline-yes">36x</span>
|
|
445
|
-
<span class="cline-any cline-yes">36x</span>
|
|
446
|
-
<span class="cline-any cline-yes">3x</span>
|
|
447
|
-
<span class="cline-any cline-yes">2x</span>
|
|
448
|
-
<span class="cline-any cline-yes">2x</span>
|
|
449
|
-
<span class="cline-any cline-yes">2x</span>
|
|
450
|
-
<span class="cline-any cline-neutral"> </span>
|
|
451
|
-
<span class="cline-any cline-neutral"> </span>
|
|
452
|
-
<span class="cline-any cline-neutral"> </span>
|
|
453
|
-
<span class="cline-any cline-yes">4x</span>
|
|
454
|
-
<span class="cline-any cline-neutral"> </span>
|
|
455
396
|
<span class="cline-any cline-neutral"> </span>
|
|
456
397
|
<span class="cline-any cline-neutral"> </span>
|
|
457
398
|
<span class="cline-any cline-neutral"> </span>
|
|
458
399
|
<span class="cline-any cline-neutral"> </span>
|
|
459
400
|
<span class="cline-any cline-neutral"> </span>
|
|
460
|
-
<span class="cline-any cline-yes">
|
|
461
|
-
<span class="cline-any cline-
|
|
462
|
-
<span class="cline-any cline-neutral"> </span>
|
|
463
|
-
<span class="cline-any cline-neutral"> </span>
|
|
401
|
+
<span class="cline-any cline-yes">7x</span>
|
|
402
|
+
<span class="cline-any cline-yes">25x</span>
|
|
464
403
|
<span class="cline-any cline-neutral"> </span>
|
|
404
|
+
<span class="cline-any cline-yes">25x</span>
|
|
465
405
|
<span class="cline-any cline-neutral"> </span>
|
|
406
|
+
<span class="cline-any cline-yes">7x</span>
|
|
466
407
|
<span class="cline-any cline-neutral"> </span>
|
|
467
408
|
<span class="cline-any cline-neutral"> </span>
|
|
468
409
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -471,9 +412,6 @@
|
|
|
471
412
|
<span class="cline-any cline-neutral"> </span>
|
|
472
413
|
<span class="cline-any cline-neutral"> </span>
|
|
473
414
|
<span class="cline-any cline-neutral"> </span>
|
|
474
|
-
<span class="cline-any cline-yes">444x</span>
|
|
475
|
-
<span class="cline-any cline-yes">42x</span>
|
|
476
|
-
<span class="cline-any cline-yes">42x</span>
|
|
477
415
|
<span class="cline-any cline-neutral"> </span>
|
|
478
416
|
<span class="cline-any cline-neutral"> </span>
|
|
479
417
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -482,40 +420,27 @@
|
|
|
482
420
|
<span class="cline-any cline-neutral"> </span>
|
|
483
421
|
<span class="cline-any cline-yes">7x</span>
|
|
484
422
|
<span class="cline-any cline-neutral"> </span>
|
|
485
|
-
<span class="cline-any cline-neutral"> </span>
|
|
486
|
-
<span class="cline-any cline-neutral"> </span>
|
|
487
|
-
<span class="cline-any cline-neutral"> </span>
|
|
488
|
-
<span class="cline-any cline-neutral"> </span>
|
|
489
|
-
<span class="cline-any cline-yes">7x</span>
|
|
490
|
-
<span class="cline-any cline-yes">25x</span>
|
|
491
|
-
<span class="cline-any cline-neutral"> </span>
|
|
492
|
-
<span class="cline-any cline-yes">25x</span>
|
|
493
|
-
<span class="cline-any cline-neutral"> </span>
|
|
494
423
|
<span class="cline-any cline-yes">7x</span>
|
|
495
424
|
<span class="cline-any cline-neutral"> </span>
|
|
496
425
|
<span class="cline-any cline-neutral"> </span>
|
|
497
426
|
<span class="cline-any cline-neutral"> </span>
|
|
498
427
|
<span class="cline-any cline-neutral"> </span>
|
|
428
|
+
<span class="cline-any cline-yes">21x</span>
|
|
499
429
|
<span class="cline-any cline-neutral"> </span>
|
|
500
430
|
<span class="cline-any cline-neutral"> </span>
|
|
501
431
|
<span class="cline-any cline-neutral"> </span>
|
|
502
432
|
<span class="cline-any cline-neutral"> </span>
|
|
503
|
-
<span class="cline-any cline-neutral"> </span>
|
|
504
|
-
<span class="cline-any cline-yes">7x</span>
|
|
505
|
-
<span class="cline-any cline-yes">7x</span>
|
|
506
433
|
<span class="cline-any cline-yes">21x</span>
|
|
507
434
|
<span class="cline-any cline-yes">21x</span>
|
|
435
|
+
<span class="cline-any cline-yes">147x</span>
|
|
508
436
|
<span class="cline-any cline-neutral"> </span>
|
|
509
437
|
<span class="cline-any cline-neutral"> </span>
|
|
438
|
+
<span class="cline-any cline-yes">21x</span>
|
|
510
439
|
<span class="cline-any cline-neutral"> </span>
|
|
511
440
|
<span class="cline-any cline-neutral"> </span>
|
|
512
441
|
<span class="cline-any cline-neutral"> </span>
|
|
513
442
|
<span class="cline-any cline-neutral"> </span>
|
|
514
443
|
<span class="cline-any cline-neutral"> </span>
|
|
515
|
-
<span class="cline-any cline-yes">21x</span>
|
|
516
|
-
<span class="cline-any cline-yes">21x</span>
|
|
517
|
-
<span class="cline-any cline-yes">147x</span>
|
|
518
|
-
<span class="cline-any cline-neutral"> </span>
|
|
519
444
|
<span class="cline-any cline-neutral"> </span>
|
|
520
445
|
<span class="cline-any cline-neutral"> </span>
|
|
521
446
|
<span class="cline-any cline-yes">7x</span>
|
|
@@ -534,6 +459,7 @@
|
|
|
534
459
|
<span class="cline-any cline-neutral"> </span>
|
|
535
460
|
<span class="cline-any cline-neutral"> </span>
|
|
536
461
|
<span class="cline-any cline-neutral"> </span>
|
|
462
|
+
<span class="cline-any cline-neutral"> </span>
|
|
537
463
|
<span class="cline-any cline-yes">7x</span>
|
|
538
464
|
<span class="cline-any cline-yes">7x</span>
|
|
539
465
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -602,12 +528,12 @@
|
|
|
602
528
|
calculateTestabilityIndex,
|
|
603
529
|
Severity,
|
|
604
530
|
IssueType,
|
|
605
|
-
|
|
531
|
+
runBatchAnalysis,
|
|
606
532
|
getParser,
|
|
607
|
-
|
|
533
|
+
isTestFile,
|
|
534
|
+
detectTestFramework,
|
|
608
535
|
} from '@aiready/core';
|
|
609
|
-
import { readFileSync
|
|
610
|
-
import { join } from 'path';
|
|
536
|
+
import { readFileSync } from 'fs';
|
|
611
537
|
import type {
|
|
612
538
|
TestabilityOptions,
|
|
613
539
|
TestabilityIssue,
|
|
@@ -639,7 +565,7 @@ async function analyzeFileTestability(filePath: string): Promise<FileAnalysis
|
|
|
639
565
|
externalStateMutations: 0,
|
|
640
566
|
};
|
|
641
567
|
|
|
642
|
-
const parser = getParser(filePath);
|
|
568
|
+
const parser = await getParser(filePath);
|
|
643
569
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (!parser) <span class="cstat-no" title="statement not covered" >return result;</span>
|
|
644
570
|
|
|
645
571
|
let code: string;
|
|
@@ -668,7 +594,7 @@ async function analyzeFileTestability(filePath: string): Promise<FileAnalysis
|
|
|
668
594
|
}
|
|
669
595
|
// Heuristic: bloated classes
|
|
670
596
|
const total = (exp.methodCount || 0) + (exp.propertyCount || 0);
|
|
671
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (total >
|
|
597
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (total > 10) {
|
|
672
598
|
<span class="cstat-no" title="statement not covered" > result.bloatedInterfaces++;</span>
|
|
673
599
|
}
|
|
674
600
|
}
|
|
@@ -676,8 +602,8 @@ async function analyzeFileTestability(filePath: string): Promise<FileAnalysis
|
|
|
676
602
|
if (exp.type === 'interface') {
|
|
677
603
|
result.totalInterfaces++;
|
|
678
604
|
// Heuristic: interfaces with many methods/props are considered bloated
|
|
679
|
-
const total = (exp.methodCount || <span class="branch-1 cbranch-no" title="branch not covered" >0) + (e</span>xp.propertyCount ||
|
|
680
|
-
<span class="missing-if-branch" title="else path not taken" >E</span>if (total >
|
|
605
|
+
const total = (exp.methodCount || <span class="branch-1 cbranch-no" title="branch not covered" >0) + (e</span>xp.propertyCount || 0);
|
|
606
|
+
<span class="missing-if-branch" title="else path not taken" >E</span>if (total > 10) {
|
|
681
607
|
result.bloatedInterfaces++;
|
|
682
608
|
}
|
|
683
609
|
}
|
|
@@ -689,60 +615,9 @@ async function analyzeFileTestability(filePath: string): Promise<FileAnalysis
|
|
|
689
615
|
return result;
|
|
690
616
|
}
|
|
691
617
|
|
|
692
|
-
// ---------------------------------------------------------------------------
|
|
693
|
-
// Test framework detection
|
|
694
|
-
// ---------------------------------------------------------------------------
|
|
695
|
-
|
|
696
|
-
function detectTestFramework(rootDir: string): boolean {
|
|
697
|
-
// Check common manifest files
|
|
698
|
-
const manifests = [
|
|
699
|
-
{
|
|
700
|
-
file: 'package.json',
|
|
701
|
-
deps: ['jest', 'vitest', 'mocha', 'mocha', 'jasmine', 'ava', 'tap'],
|
|
702
|
-
},
|
|
703
|
-
{ file: 'requirements.txt', deps: ['pytest', 'unittest', 'nose'] },
|
|
704
|
-
{ file: 'pyproject.toml', deps: ['pytest'] },
|
|
705
|
-
{ file: 'pom.xml', deps: ['junit', 'testng'] },
|
|
706
|
-
{ file: 'build.gradle', deps: ['junit', 'testng'] },
|
|
707
|
-
{ file: 'go.mod', deps: ['testing'] }, // go testing is built-in
|
|
708
|
-
];
|
|
709
|
-
|
|
710
|
-
for (const m of manifests) {
|
|
711
|
-
const p = join(rootDir, m.file);
|
|
712
|
-
if (existsSync(p)) {
|
|
713
|
-
if (m.file === 'go.mod') return true; // built-in
|
|
714
|
-
try {
|
|
715
|
-
const content = readFileSync(p, 'utf-8');
|
|
716
|
-
<span class="missing-if-branch" title="else path not taken" >E</span>if (m.deps.some((d) => content.includes(d))) return true;
|
|
717
|
-
} catch {}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
return false;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// ---------------------------------------------------------------------------
|
|
724
618
|
// Main analyzer
|
|
725
619
|
// ---------------------------------------------------------------------------
|
|
726
620
|
|
|
727
|
-
const TEST_PATTERNS = [
|
|
728
|
-
/\.(test|spec)\.(ts|tsx|js|jsx)$/,
|
|
729
|
-
/_test\.go$/,
|
|
730
|
-
/test_.*\.py$/,
|
|
731
|
-
/.*_test\.py$/,
|
|
732
|
-
/.*Test\.java$/,
|
|
733
|
-
/.*Tests\.cs$/,
|
|
734
|
-
/__tests__\//,
|
|
735
|
-
/\/tests?\//,
|
|
736
|
-
/\/e2e\//,
|
|
737
|
-
/\/fixtures\//,
|
|
738
|
-
];
|
|
739
|
-
|
|
740
|
-
function isTestFile(filePath: string, extra?: string[]): boolean {
|
|
741
|
-
if (TEST_PATTERNS.some((p) => p.test(filePath))) return true;
|
|
742
|
-
<span class="missing-if-branch" title="if path not taken" >I</span>if (extra) return extra.some(<span class="fstat-no" title="function not covered" >(p</span>) => <span class="cstat-no" title="statement not covered" >filePath.includes(p))</span>;
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
621
|
export async function analyzeTestability(
|
|
747
622
|
options: TestabilityOptions
|
|
748
623
|
): Promise<TestabilityReport> {
|
|
@@ -768,22 +643,35 @@ export async function analyzeTestability(
|
|
|
768
643
|
externalStateMutations: 0,
|
|
769
644
|
};
|
|
770
645
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
'testability',
|
|
778
|
-
'analyzing files',
|
|
779
|
-
options.onProgress
|
|
780
|
-
);
|
|
646
|
+
// Collect file-level details for smarter scoring
|
|
647
|
+
const fileDetails: Array<{
|
|
648
|
+
filePath: string;
|
|
649
|
+
pureFunctions: number;
|
|
650
|
+
totalFunctions: number;
|
|
651
|
+
}> = [];
|
|
781
652
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
653
|
+
await runBatchAnalysis(
|
|
654
|
+
sourceFiles,
|
|
655
|
+
'analyzing files',
|
|
656
|
+
'testability',
|
|
657
|
+
options.onProgress,
|
|
658
|
+
async (f: string) => ({
|
|
659
|
+
filePath: f,
|
|
660
|
+
analysis: await analyzeFileTestability(f),
|
|
661
|
+
}),
|
|
662
|
+
(result: { filePath: string; analysis: FileAnalysis }) => {
|
|
663
|
+
const a = result.analysis;
|
|
664
|
+
for (const key of Object.keys(aggregated) as Array<keyof FileAnalysis>) {
|
|
665
|
+
aggregated[key] += a[key];
|
|
666
|
+
}
|
|
667
|
+
// Collect file-level data
|
|
668
|
+
fileDetails.push({
|
|
669
|
+
filePath: result.filePath,
|
|
670
|
+
pureFunctions: a.pureFunctions,
|
|
671
|
+
totalFunctions: a.totalFunctions,
|
|
672
|
+
});
|
|
785
673
|
}
|
|
786
|
-
|
|
674
|
+
);
|
|
787
675
|
|
|
788
676
|
const hasTestFramework = detectTestFramework(options.rootDir);
|
|
789
677
|
|
|
@@ -798,6 +686,7 @@ export async function analyzeTestability(
|
|
|
798
686
|
totalInterfaces: Math.max(1, aggregated.totalInterfaces),
|
|
799
687
|
externalStateMutations: aggregated.externalStateMutations,
|
|
800
688
|
hasTestFramework,
|
|
689
|
+
fileDetails,
|
|
801
690
|
});
|
|
802
691
|
|
|
803
692
|
// Build issues
|
|
@@ -871,7 +760,7 @@ export async function analyzeTestability(
|
|
|
871
760
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
872
761
|
Code coverage generated by
|
|
873
762
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
874
|
-
at 2026-03-
|
|
763
|
+
at 2026-03-24T09:07:15.069Z
|
|
875
764
|
</div>
|
|
876
765
|
<script src="prettify.js"></script>
|
|
877
766
|
<script>
|
package/coverage/clover.xml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
4
|
-
<metrics statements="
|
|
2
|
+
<coverage generated="1774343235074" clover="3.2.0">
|
|
3
|
+
<project timestamp="1774343235074" name="All files">
|
|
4
|
+
<metrics statements="62" coveredstatements="59" conditionals="48" coveredconditionals="41" methods="13" coveredmethods="12" elements="123" coveredelements="112" complexity="0" loc="62" ncloc="62" packages="1" files="3" classes="3"/>
|
|
5
5
|
<file name="analyzer.ts" path="/Users/pengcao/projects/aiready/packages/testability/src/analyzer.ts">
|
|
6
|
-
<metrics statements="
|
|
6
|
+
<metrics statements="53" coveredstatements="50" conditionals="42" coveredconditionals="35" methods="6" coveredmethods="6"/>
|
|
7
7
|
<line num="33" count="21" type="stmt"/>
|
|
8
8
|
<line num="43" count="21" type="stmt"/>
|
|
9
9
|
<line num="44" count="21" type="cond" truecount="1" falsecount="1"/>
|
|
@@ -27,66 +27,51 @@
|
|
|
27
27
|
<line num="73" count="0" type="stmt"/>
|
|
28
28
|
<line num="77" count="17" type="cond" truecount="2" falsecount="0"/>
|
|
29
29
|
<line num="78" count="2" type="stmt"/>
|
|
30
|
-
<line num="80" count="2" type="cond" truecount="
|
|
30
|
+
<line num="80" count="2" type="cond" truecount="3" falsecount="1"/>
|
|
31
31
|
<line num="81" count="2" type="cond" truecount="1" falsecount="1"/>
|
|
32
32
|
<line num="82" count="2" type="stmt"/>
|
|
33
33
|
<line num="87" count="0" type="stmt"/>
|
|
34
34
|
<line num="90" count="21" type="stmt"/>
|
|
35
|
-
<line num="
|
|
35
|
+
<line num="100" count="7" type="stmt"/>
|
|
36
|
+
<line num="106" count="7" type="stmt"/>
|
|
37
|
+
<line num="107" count="25" type="stmt"/>
|
|
38
|
+
<line num="109" count="25" type="stmt"/>
|
|
36
39
|
<line num="111" count="7" type="stmt"/>
|
|
37
|
-
<line num="
|
|
38
|
-
<line num="
|
|
39
|
-
<line num="
|
|
40
|
-
<line num="
|
|
41
|
-
<line num="
|
|
42
|
-
<line num="
|
|
43
|
-
<line num="
|
|
44
|
-
<line num="128" count="1" type="stmt"/>
|
|
45
|
-
<line num="142" count="444" type="cond" truecount="2" falsecount="0"/>
|
|
46
|
-
<line num="143" count="42" type="cond" truecount="1" falsecount="1"/>
|
|
47
|
-
<line num="144" count="42" type="stmt"/>
|
|
40
|
+
<line num="126" count="7" type="stmt"/>
|
|
41
|
+
<line num="128" count="7" type="stmt"/>
|
|
42
|
+
<line num="133" count="21" type="stmt"/>
|
|
43
|
+
<line num="138" count="21" type="stmt"/>
|
|
44
|
+
<line num="139" count="21" type="stmt"/>
|
|
45
|
+
<line num="140" count="147" type="stmt"/>
|
|
46
|
+
<line num="143" count="21" type="stmt"/>
|
|
48
47
|
<line num="151" count="7" type="stmt"/>
|
|
49
|
-
<line num="
|
|
50
|
-
<line num="
|
|
51
|
-
<line num="
|
|
52
|
-
<line num="
|
|
53
|
-
<line num="
|
|
54
|
-
<line num="
|
|
55
|
-
<line num="
|
|
56
|
-
<line num="
|
|
57
|
-
<line num="
|
|
58
|
-
<line num="
|
|
59
|
-
<line num="
|
|
60
|
-
<line num="
|
|
61
|
-
<line num="191" count="7" type="stmt"/>
|
|
62
|
-
<line num="205" count="7" type="stmt"/>
|
|
63
|
-
<line num="206" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
64
|
-
<line num="208" count="7" type="cond" truecount="1" falsecount="1"/>
|
|
65
|
-
<line num="210" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
66
|
-
<line num="211" count="4" type="stmt"/>
|
|
67
|
-
<line num="223" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
68
|
-
<line num="225" count="6" type="stmt"/>
|
|
69
|
-
<line num="226" count="6" type="stmt"/>
|
|
70
|
-
<line num="236" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
71
|
-
<line num="237" count="3" type="stmt"/>
|
|
72
|
-
<line num="248" count="7" type="stmt"/>
|
|
48
|
+
<line num="153" count="7" type="stmt"/>
|
|
49
|
+
<line num="168" count="7" type="stmt"/>
|
|
50
|
+
<line num="169" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
51
|
+
<line num="171" count="7" type="cond" truecount="1" falsecount="1"/>
|
|
52
|
+
<line num="173" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
53
|
+
<line num="174" count="4" type="stmt"/>
|
|
54
|
+
<line num="186" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
55
|
+
<line num="188" count="6" type="stmt"/>
|
|
56
|
+
<line num="189" count="6" type="stmt"/>
|
|
57
|
+
<line num="199" count="7" type="cond" truecount="2" falsecount="0"/>
|
|
58
|
+
<line num="200" count="3" type="stmt"/>
|
|
59
|
+
<line num="211" count="7" type="stmt"/>
|
|
73
60
|
</file>
|
|
74
61
|
<file name="provider.ts" path="/Users/pengcao/projects/aiready/packages/testability/src/provider.ts">
|
|
75
|
-
<metrics statements="
|
|
76
|
-
<line num="
|
|
77
|
-
<line num="
|
|
78
|
-
<line num="
|
|
62
|
+
<metrics statements="7" coveredstatements="7" conditionals="2" coveredconditionals="2" methods="6" coveredmethods="5"/>
|
|
63
|
+
<line num="14" count="1" type="stmt"/>
|
|
64
|
+
<line num="20" count="1" type="stmt"/>
|
|
65
|
+
<line num="23" count="1" type="stmt"/>
|
|
79
66
|
<line num="32" count="1" type="stmt"/>
|
|
80
|
-
<line num="
|
|
81
|
-
<line num="
|
|
67
|
+
<line num="35" count="1" type="stmt"/>
|
|
68
|
+
<line num="38" count="1" type="stmt"/>
|
|
69
|
+
<line num="43" count="1" type="stmt"/>
|
|
82
70
|
</file>
|
|
83
71
|
<file name="scoring.ts" path="/Users/pengcao/projects/aiready/packages/testability/src/scoring.ts">
|
|
84
|
-
<metrics statements="
|
|
85
|
-
<line num="
|
|
86
|
-
<line num="
|
|
87
|
-
<line num="40" count="4" type="stmt"/>
|
|
88
|
-
<line num="41" count="3" type="stmt"/>
|
|
89
|
-
<line num="52" count="4" type="stmt"/>
|
|
72
|
+
<metrics statements="2" coveredstatements="2" conditionals="4" coveredconditionals="4" methods="1" coveredmethods="1"/>
|
|
73
|
+
<line num="8" count="7" type="stmt"/>
|
|
74
|
+
<line num="10" count="7" type="stmt"/>
|
|
90
75
|
</file>
|
|
91
76
|
</project>
|
|
92
77
|
</coverage>
|