checkchange 0.4.3 → 0.5.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.
- package/README.md +49 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +3 -4
- package/dist/complexity-providers/csharpDescriptorProvider.js +2 -2
- package/dist/complexity-providers/csharpFallbackParser.js +29 -2
- package/dist/coverage.js +57 -5
- package/dist/crapCalc.d.ts +1 -1
- package/dist/crapCalc.js +1 -1
- package/dist/delta.d.ts +3 -3
- package/dist/evidence.d.ts +3 -2
- package/dist/evidence.js +14 -8
- package/dist/formatters/index.d.ts +1 -1
- package/dist/providers/config.js +4 -3
- package/dist/rules.d.ts +1 -1
- package/dist/rules.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ Those are evidence states, not judgments about whether the software is ultimatel
|
|
|
109
109
|
|
|
110
110
|
The package is published on npm as `checkchange`.
|
|
111
111
|
|
|
112
|
-
Current registry version: **0.4.
|
|
112
|
+
Current registry version: **0.4.4**
|
|
113
113
|
|
|
114
114
|
### npm
|
|
115
115
|
|
|
@@ -364,6 +364,32 @@ coverageArtifact: present
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
+
# Gate contract
|
|
368
|
+
|
|
369
|
+
The `gate` field of the evidence output is never null (as of 0.5.0). It is one
|
|
370
|
+
of four values:
|
|
371
|
+
|
|
372
|
+
| `gate` | Meaning |
|
|
373
|
+
|---|---|
|
|
374
|
+
| `PASS` | No rule violations and coverage sufficient. |
|
|
375
|
+
| `WARN` | At least one rule violated (e.g. CRAP above threshold). |
|
|
376
|
+
| `NOT_EVALUATED` | Nothing to evaluate (unsupported source, empty intervals, absent coverage). |
|
|
377
|
+
| `FAILED` | Analysis could not complete (coverage missing/malformed, complexity failed). |
|
|
378
|
+
|
|
379
|
+
`gateReason` (optional) explains why a non-PASS gate was emitted, e.g.
|
|
380
|
+
`no-supported-file-extensions`, `complexity-analysis-failed`, or the coverage
|
|
381
|
+
error reason (`missing` / `malformed` / `failed`).
|
|
382
|
+
|
|
383
|
+
Exit codes:
|
|
384
|
+
|
|
385
|
+
| Condition | Exit code |
|
|
386
|
+
|---|---|
|
|
387
|
+
| `FAILED` analysisStatus or `gate === 'FAILED'` | 1 |
|
|
388
|
+
| `gate === 'WARN'` | 1 |
|
|
389
|
+
| `PASS` / `NOT_EVALUATED` | 0 |
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
367
393
|
# Why the evidence matters
|
|
368
394
|
|
|
369
395
|
One of the design goals of CheckChange is to distinguish **"we measured it"** from **"we don't have enough evidence."**
|
|
@@ -437,6 +463,28 @@ This makes it possible to use the same evidence both for human-facing developmen
|
|
|
437
463
|
|
|
438
464
|
---
|
|
439
465
|
|
|
466
|
+
# Delta input paths
|
|
467
|
+
|
|
468
|
+
`checkchange delta --baseline <path> --current <path>` reads both evidence
|
|
469
|
+
artifacts through a fail-closed containment seam (`src/fs-safety.ts`): the
|
|
470
|
+
resolved (realpath-expanded) file must be inside the current working
|
|
471
|
+
directory. Absolute paths outside the cwd — and symlink targets that escape
|
|
472
|
+
it — are rejected with `delta: input path escapes cwd: <path>` and exit 1.
|
|
473
|
+
|
|
474
|
+
Run `delta` from the directory that contains the artifacts, or pass paths
|
|
475
|
+
relative to it:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
checkchange delta --baseline evidence-a.json --current evidence-b.json --json
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Note the deliberate asymmetry: an explicit `check --coverage-file <path>`
|
|
482
|
+
*is* allowed outside the cwd (user-provided artifacts are trusted), while
|
|
483
|
+
delta inputs are not. Auto-detected coverage files use the same containment
|
|
484
|
+
seam as delta.
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
440
488
|
# Dependencies and external tools
|
|
441
489
|
|
|
442
490
|
CheckChange uses a small number of external packages and tools for its analysis.
|
package/dist/cli.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface CheckArgs {
|
|
|
15
15
|
export declare function parseCliArgs(argv?: string[]): CheckArgs;
|
|
16
16
|
interface EvidenceOutputShape {
|
|
17
17
|
analysisStatus: string;
|
|
18
|
-
gate:
|
|
18
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
19
19
|
completeness: string;
|
|
20
20
|
changedFunctions: Array<Record<string, unknown>>;
|
|
21
21
|
ruleResults: Array<{
|
package/dist/cli.js
CHANGED
|
@@ -242,7 +242,7 @@ export function formatOutput(output, opts, resolvedBase, cacheEnabled) {
|
|
|
242
242
|
}
|
|
243
243
|
else {
|
|
244
244
|
// For WP1, we primarily want JSON, but let's output a simple summary if not JSON
|
|
245
|
-
console.log(`Analysis complete. Base: ${resolvedBase}, Changed functions: ${output.changedFunctions.length}`);
|
|
245
|
+
console.log(`Analysis complete. Base: ${resolvedBase}, Changed functions: ${output.changedFunctions.length}, Gate: ${output.gate}`);
|
|
246
246
|
// H2: a FALLBACK complexity stage is otherwise invisible in the text path —
|
|
247
247
|
// the run reports PASS/NOT_EVALUATED over approximate measurements. Warn on
|
|
248
248
|
// stderr (stdout stays the machine-readable summary); nothing is printed when
|
|
@@ -269,9 +269,8 @@ export function formatOutput(output, opts, resolvedBase, cacheEnabled) {
|
|
|
269
269
|
exitCode = 1;
|
|
270
270
|
}
|
|
271
271
|
else if (output.analysisStatus === 'UNSUPPORTED') {
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
if (output.gate !== null && output.gate !== 'NOT_EVALUATED') {
|
|
272
|
+
// NOT_EVALUATED / PASS → exit 0; WARN → exit 1. (gate is never null post-0.5.0)
|
|
273
|
+
if (output.gate === 'WARN') {
|
|
275
274
|
exitCode = 1;
|
|
276
275
|
}
|
|
277
276
|
}
|
|
@@ -174,10 +174,10 @@ export function vehicleRejection() {
|
|
|
174
174
|
return lastVehicleRejection;
|
|
175
175
|
}
|
|
176
176
|
// The fallback parser is checkchange's OWN code (./csharpFallbackParser.ts), so
|
|
177
|
-
// its tool is checkchange and its version is the package version — same 0.
|
|
177
|
+
// its tool is checkchange and its version is the package version — same 0.5.0
|
|
178
178
|
// the other self-provenance consts hard-code (src/crapCalc.ts:3, src/rules.ts:4).
|
|
179
179
|
const FALLBACK_TOOL = 'checkchange';
|
|
180
|
-
const FALLBACK_TOOL_VERSION = '0.
|
|
180
|
+
const FALLBACK_TOOL_VERSION = '0.5.0';
|
|
181
181
|
// The vehicle's INSTALLED version is never probed: the rich path is
|
|
182
182
|
// documented-unreachable (see SPAWN FORM above), so `dotnet-crap --version` is
|
|
183
183
|
// never spawned to learn it, and no version is fabricated here. `unknown` is the
|
|
@@ -51,6 +51,12 @@
|
|
|
51
51
|
* - Constructors ARE reported, as functionName === the type name (so
|
|
52
52
|
* displayName is `Foo.Foo`). Rich-path naming may differ; that difference is
|
|
53
53
|
* in the pinned delta table.
|
|
54
|
+
* - Primary-constructor TYPE DECLARATIONS (`public record R(int X)`,
|
|
55
|
+
* `public record struct S(int Y)`, `public class C(int Z)`) are containers,
|
|
56
|
+
* not methods: their members are reported normally and no phantom descriptor
|
|
57
|
+
* named after the type is emitted. `isMethodHead` returns null for them, so
|
|
58
|
+
* the head reaches the CONTAINER_RE branch instead of the pushMember branch.
|
|
59
|
+
* `record struct X` captures `X`, not `struct`.
|
|
54
60
|
* - Malformed source degrades to whatever was recognised before the imbalance; a
|
|
55
61
|
* file with no recognisable method yields `[]`. Degradation is NON-THROWING
|
|
56
62
|
* but not faithful, and the deviation is worse than "stopped early": an
|
|
@@ -78,7 +84,10 @@ const STATEMENT_KEYWORDS = new Set([
|
|
|
78
84
|
'sizeof', 'stackalloc', 'struct', 'switch', 'this', 'throw', 'try', 'typeof', 'unchecked', 'unsafe', 'using',
|
|
79
85
|
'value', 'var', 'when', 'where', 'while', 'with', 'yield',
|
|
80
86
|
]);
|
|
81
|
-
|
|
87
|
+
// The `record (struct|class)` alternative MUST come first: C# `record struct X`
|
|
88
|
+
// is a type declaration named `X`, and the plain `record` alternative would
|
|
89
|
+
// otherwise match first and capture `struct` as the container name.
|
|
90
|
+
const CONTAINER_RE = /\b(?:record\s+(?:struct|class)|class|struct|interface|record|enum)\s+([A-Za-z_]\w*)/;
|
|
82
91
|
// One pass, ordered alternation. Word-boundary keywords first (so `foreach` is
|
|
83
92
|
// not also counted as `for`), then the boolean operators, then `??`, then the
|
|
84
93
|
// ternary.
|
|
@@ -302,7 +311,25 @@ function signatureOf(head) {
|
|
|
302
311
|
return { name, returnPart: before.slice(0, before.length - name.length).trim(), head: stripped };
|
|
303
312
|
}
|
|
304
313
|
function isMethodHead(head, containerName) {
|
|
305
|
-
|
|
314
|
+
// A type DECLARATION head is never a method. Checked FIRST, before any `(` /
|
|
315
|
+
// `returnPart` gate, because the gate that used to catch it read the FIRST
|
|
316
|
+
// token of the head — and on `public record CtorRecord(int X)` that is
|
|
317
|
+
// `public`, which is NOT in STATEMENT_KEYWORDS (record/class/struct ARE, but
|
|
318
|
+
// they are not first). So a primary-constructor type produced a phantom
|
|
319
|
+
// method NAMED AFTER THE TYPE and, worse, the `{` caller then did
|
|
320
|
+
// `i = close + 1` past its whole body, silently dropping every real member
|
|
321
|
+
// inside. Returning null routes the head to the CONTAINER_RE branch instead,
|
|
322
|
+
// where its members are scanned normally.
|
|
323
|
+
//
|
|
324
|
+
// ponytail: reuses CONTAINER_RE rather than a second keyword regex — the
|
|
325
|
+
// guard is exactly "this head is a type declaration AND carries a parameter
|
|
326
|
+
// list", which is the primary-constructor shape. `where T : class` and
|
|
327
|
+
// `where T : class, new()` are constrained METHOD heads and do NOT match
|
|
328
|
+
// (their `class` is followed by `,`/nothing, never by an identifier).
|
|
329
|
+
const strippedHead = stripAttributes(head);
|
|
330
|
+
if (CONTAINER_RE.test(strippedHead) && strippedHead.includes('('))
|
|
331
|
+
return null;
|
|
332
|
+
const sig = signatureOf(strippedHead);
|
|
306
333
|
if (!sig)
|
|
307
334
|
return null;
|
|
308
335
|
// Read the first token from the attribute-stripped head, not the raw one.
|
package/dist/coverage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
|
-
import { access, constants, readFile } from 'node:fs/promises';
|
|
3
|
+
import { access, constants, readFile, readdir } from 'node:fs/promises';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { parseCoverageReport } from '@barney-media/crap-typescript-core';
|
|
@@ -501,9 +501,13 @@ export async function readCoverage(cwd, coverageFile, trace, autoGenerated) {
|
|
|
501
501
|
? [...new Set([...registry.values()].flatMap((r) => r.coverageFiles))]
|
|
502
502
|
: [...PYTHON_COVERAGE_FILES];
|
|
503
503
|
for (const file of coverageCandidates) {
|
|
504
|
-
|
|
504
|
+
// WS4: the exact literal is still tried FIRST (precedence unchanged), and only a
|
|
505
|
+
// miss falls through to a case-insensitive lookup in the candidate's own directory.
|
|
506
|
+
// null = miss, skipped exactly as silently as before.
|
|
507
|
+
const filePath = await resolveReadableCandidate(cwd, file);
|
|
508
|
+
if (filePath === null)
|
|
509
|
+
continue;
|
|
505
510
|
try {
|
|
506
|
-
await access(filePath, constants.R_OK);
|
|
507
511
|
artifactFound = true;
|
|
508
512
|
const result = await readCoverageFile(filePath, cwd, false);
|
|
509
513
|
// Conversion/read succeeded — ACCUMULATE, never return early
|
|
@@ -527,7 +531,8 @@ export async function readCoverage(cwd, coverageFile, trace, autoGenerated) {
|
|
|
527
531
|
// Continue to next file in precedence
|
|
528
532
|
}
|
|
529
533
|
catch {
|
|
530
|
-
//
|
|
534
|
+
// Read/conversion threw (it normally returns a result object instead) — continue
|
|
535
|
+
// to the next candidate, same as before.
|
|
531
536
|
}
|
|
532
537
|
}
|
|
533
538
|
// ponytail: a literal candidate produced a map — the merged result wins and the
|
|
@@ -577,6 +582,53 @@ export async function readCoverage(cwd, coverageFile, trace, autoGenerated) {
|
|
|
577
582
|
return { available: false, coverageMap: null, error: false };
|
|
578
583
|
}
|
|
579
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* Resolve one literal coverage candidate to a readable path, or null on a miss.
|
|
587
|
+
*
|
|
588
|
+
* The EXACT literal is tried first and returns unchanged, so precedence is untouched: a
|
|
589
|
+
* candidate that exists keeps winning over any case-variant sibling beside it. Only on a
|
|
590
|
+
* miss do we list the candidate's OWN directory — a single `readdir`, no recursion, depth
|
|
591
|
+
* fixed at one — and take the first name matching case-insensitively.
|
|
592
|
+
*
|
|
593
|
+
* Why here and not in the config literals: `access()` is case-sensitive on Linux ext4, so
|
|
594
|
+
* an artifact emitted as `COVERAGE.XML` was invisible to discovery there while the same
|
|
595
|
+
* repo reported coverage on macOS's case-insensitive APFS. Fixing discovery (not the
|
|
596
|
+
* literal list) makes every provider's `coverageFiles` benefit, and it cannot turn a glob
|
|
597
|
+
* entry into something that works: exactly one basename is ever consulted.
|
|
598
|
+
*/
|
|
599
|
+
async function resolveReadableCandidate(cwd, file) {
|
|
600
|
+
const exact = path.join(cwd, file);
|
|
601
|
+
try {
|
|
602
|
+
await access(exact, constants.R_OK);
|
|
603
|
+
return exact;
|
|
604
|
+
}
|
|
605
|
+
catch {
|
|
606
|
+
// Miss — fall through to the case-insensitive sibling lookup.
|
|
607
|
+
}
|
|
608
|
+
const dir = path.dirname(exact);
|
|
609
|
+
const wanted = path.basename(exact).toLowerCase();
|
|
610
|
+
let names;
|
|
611
|
+
try {
|
|
612
|
+
names = await readdir(dir);
|
|
613
|
+
}
|
|
614
|
+
catch {
|
|
615
|
+
// Missing/unreadable directory — a miss, skipped silently exactly as before. A cwd
|
|
616
|
+
// that is a FILE also lands here (ENOTDIR), which is the degradation the WS3.4 arms
|
|
617
|
+
// pin for the scan.
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
const hit = names.find((name) => name.toLowerCase() === wanted);
|
|
621
|
+
if (hit === undefined)
|
|
622
|
+
return null;
|
|
623
|
+
const sibling = path.join(dir, hit);
|
|
624
|
+
try {
|
|
625
|
+
await access(sibling, constants.R_OK);
|
|
626
|
+
return sibling;
|
|
627
|
+
}
|
|
628
|
+
catch {
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
580
632
|
/**
|
|
581
633
|
* Detect the coverage format and dispatch to the matching parser.
|
|
582
634
|
*
|
|
@@ -665,7 +717,7 @@ async function readCoverageFile(coveragePath, cwd, isExplicit, autoGenerated) {
|
|
|
665
717
|
// conversion and returning reason 'malformed' (:548) before any format
|
|
666
718
|
// dispatch ran. `.cobertura.xml` is Cobertura; only `coverage.xml` is the
|
|
667
719
|
// pytest-cov artifact `coverage json` can read.
|
|
668
|
-
const isPythonCoverageXml = ext === '.xml' && basename === 'coverage.xml';
|
|
720
|
+
const isPythonCoverageXml = ext === '.xml' && basename.toLowerCase() === 'coverage.xml';
|
|
669
721
|
// For Python .coverage binary or coverage.xml, try to convert to JSON first
|
|
670
722
|
let actualPath = coveragePath;
|
|
671
723
|
let tempFileToCleanup = null;
|
package/dist/crapCalc.d.ts
CHANGED
package/dist/crapCalc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Provenance for the crapCalc lineage stage. Self tool version tracks package.json
|
|
2
2
|
// (matches existing hard-coded '0.5.0' style for the core package).
|
|
3
|
-
export const crapCalcProvenance = { tool: 'checkchange', version: '0.
|
|
3
|
+
export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.0' };
|
|
4
4
|
export function calculateCrap(cc, coveragePercent) {
|
|
5
5
|
if (coveragePercent == null) {
|
|
6
6
|
return null;
|
package/dist/delta.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface EvidenceOutput {
|
|
|
19
19
|
};
|
|
20
20
|
ruleResults: RuleResult[];
|
|
21
21
|
analysisStatus: string;
|
|
22
|
-
gate:
|
|
22
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
23
23
|
completeness: string;
|
|
24
24
|
coverageErrorReason?: string;
|
|
25
25
|
diagnostics?: {
|
|
@@ -35,13 +35,13 @@ export interface DeltaOutput {
|
|
|
35
35
|
baseline: {
|
|
36
36
|
base: string;
|
|
37
37
|
analysisStatus: string;
|
|
38
|
-
gate:
|
|
38
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
39
39
|
changedFunctions: number;
|
|
40
40
|
};
|
|
41
41
|
current: {
|
|
42
42
|
base: string;
|
|
43
43
|
analysisStatus: string;
|
|
44
|
-
gate:
|
|
44
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
45
45
|
changedFunctions: number;
|
|
46
46
|
};
|
|
47
47
|
thresholds: {
|
package/dist/evidence.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface DiagnosticLineageEntry {
|
|
|
31
31
|
}
|
|
32
32
|
export declare const evidenceProvenance: {
|
|
33
33
|
readonly tool: "checkchange";
|
|
34
|
-
readonly version: "0.
|
|
34
|
+
readonly version: "0.5.0";
|
|
35
35
|
};
|
|
36
36
|
export interface EvidenceOutput {
|
|
37
37
|
schemaVersion: string;
|
|
@@ -50,9 +50,10 @@ export interface EvidenceOutput {
|
|
|
50
50
|
};
|
|
51
51
|
ruleResults: RuleResult[];
|
|
52
52
|
analysisStatus: string;
|
|
53
|
-
gate:
|
|
53
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
54
54
|
completeness: string;
|
|
55
55
|
coverageErrorReason?: string;
|
|
56
|
+
gateReason?: string;
|
|
56
57
|
diagnostics?: {
|
|
57
58
|
lineage: DiagnosticLineageEntry[];
|
|
58
59
|
quality: DiagnosticQuality;
|
package/dist/evidence.js
CHANGED
|
@@ -20,7 +20,7 @@ import * as path from 'path';
|
|
|
20
20
|
import { loadProviderConfig, deriveRegistry, builtinConfig, createGenericCommandProvider } from './providers/index.js';
|
|
21
21
|
const requireFromEvidence = createRequire(import.meta.url);
|
|
22
22
|
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.0').
|
|
23
|
-
export const evidenceProvenance = { tool: 'checkchange', version: '0.
|
|
23
|
+
export const evidenceProvenance = { tool: 'checkchange', version: '0.5.0' };
|
|
24
24
|
function sha256Hex(content) {
|
|
25
25
|
return createHash('sha256').update(content).digest('hex');
|
|
26
26
|
}
|
|
@@ -532,6 +532,7 @@ async function emptyIntervalsReturn(base, threshold, detectedExtension, cwd, cov
|
|
|
532
532
|
analysisStatus: 'UNSUPPORTED',
|
|
533
533
|
gate: 'NOT_EVALUATED',
|
|
534
534
|
completeness: 'INCOMPLETE',
|
|
535
|
+
gateReason: 'no-changed-lines',
|
|
535
536
|
...(covEarly.errorReason !== undefined ? { coverageErrorReason: covEarly.errorReason } : {})
|
|
536
537
|
}, lineage, buildQuality({ complexityCapability: 'unavailable', coverageUsable: false }));
|
|
537
538
|
}
|
|
@@ -634,7 +635,7 @@ export function buildOutput(base, changed, threshold = 30, capabilities = { git:
|
|
|
634
635
|
*/
|
|
635
636
|
function resolveCoverageFailure(coverageCapability, coverageErrorReason, autoGenerated, base, gitCapability, complexityCapability, threshold, lineage, complexityCapabilityForQuality, complexityQuality) {
|
|
636
637
|
let analysisStatus = 'SUCCESS';
|
|
637
|
-
let gate =
|
|
638
|
+
let gate = '';
|
|
638
639
|
let completeness = 'COMPLETE';
|
|
639
640
|
if (coverageCapability === 'failed') {
|
|
640
641
|
if (autoGenerated) {
|
|
@@ -780,8 +781,9 @@ export async function buildEvidenceOutput(base, intervals, cwd, threshold = 30,
|
|
|
780
781
|
crapThreshold: threshold
|
|
781
782
|
},
|
|
782
783
|
analysisStatus: 'UNSUPPORTED',
|
|
783
|
-
gate:
|
|
784
|
-
completeness: 'INCOMPLETE'
|
|
784
|
+
gate: 'NOT_EVALUATED',
|
|
785
|
+
completeness: 'INCOMPLETE',
|
|
786
|
+
gateReason: 'no-supported-file-extensions'
|
|
785
787
|
}, lineage, buildQuality({ complexityCapability, complexityQuality: measurementQuality(complexityInfo), coverageUsable: false }));
|
|
786
788
|
}
|
|
787
789
|
// Step 2: Read coverage
|
|
@@ -816,8 +818,9 @@ export async function buildEvidenceOutput(base, intervals, cwd, threshold = 30,
|
|
|
816
818
|
},
|
|
817
819
|
ruleResults: [],
|
|
818
820
|
analysisStatus: 'UNSUPPORTED',
|
|
819
|
-
gate:
|
|
820
|
-
completeness: 'NOT_APPLICABLE'
|
|
821
|
+
gate: 'NOT_EVALUATED',
|
|
822
|
+
completeness: 'NOT_APPLICABLE',
|
|
823
|
+
gateReason: 'complexity-analysis-failed'
|
|
821
824
|
}, lineage, buildQuality({ complexityCapability, complexityQuality: measurementQuality(complexityInfo), coverageUsable: false }));
|
|
822
825
|
return earlyReturn;
|
|
823
826
|
}
|
|
@@ -850,6 +853,7 @@ export async function buildEvidenceOutput(base, intervals, cwd, threshold = 30,
|
|
|
850
853
|
// Step 8: Compute overall gate and completeness
|
|
851
854
|
let { gate: gateValue, completeness: completenessValue } = computeGateAndCompleteness(ruleResults);
|
|
852
855
|
// §5 vacuous-PASS ban: coverage absent + needs coverage → NOT_EVALUATED gate.
|
|
856
|
+
const coverageAbsentFlip = coverageCapability === 'absent' && changedFunctions.length > 0;
|
|
853
857
|
gateValue = applyAbsentCoverageGate(gateValue, coverageCapability, changedFunctions.length);
|
|
854
858
|
// Step 9: Determine analysisStatus
|
|
855
859
|
// If we have no relevant TS functions after successful analysis -> SUCCESS
|
|
@@ -901,7 +905,8 @@ export async function buildEvidenceOutput(base, intervals, cwd, threshold = 30,
|
|
|
901
905
|
ruleResults: ruleResults,
|
|
902
906
|
analysisStatus: analysisStatus,
|
|
903
907
|
gate: gateValue,
|
|
904
|
-
completeness: completenessValue
|
|
908
|
+
completeness: completenessValue,
|
|
909
|
+
...(coverageAbsentFlip ? { gateReason: 'coverage-absent' } : {})
|
|
905
910
|
}, lineage, buildQuality({
|
|
906
911
|
complexityCapability,
|
|
907
912
|
complexityQuality: measurementQuality(complexityInfo),
|
|
@@ -930,8 +935,9 @@ function buildFailedOutput(base, gitCapability, complexityCapability, coverageCa
|
|
|
930
935
|
},
|
|
931
936
|
ruleResults: [],
|
|
932
937
|
analysisStatus: 'FAILED',
|
|
933
|
-
gate:
|
|
938
|
+
gate: 'FAILED',
|
|
934
939
|
completeness: 'INCOMPLETE',
|
|
940
|
+
gateReason: coverageErrorReason !== undefined ? coverageErrorReason : 'analysis-failed',
|
|
935
941
|
...(coverageErrorReason !== undefined ? { coverageErrorReason } : {}),
|
|
936
942
|
};
|
|
937
943
|
}
|
|
@@ -34,7 +34,7 @@ export interface RuleResultShape {
|
|
|
34
34
|
* formatters define their own and CLI passes its cast output in Task 2). */
|
|
35
35
|
export interface EvidenceOutputShape {
|
|
36
36
|
analysisStatus: string;
|
|
37
|
-
gate:
|
|
37
|
+
gate: 'PASS' | 'WARN' | 'NOT_EVALUATED' | 'FAILED';
|
|
38
38
|
completeness: string;
|
|
39
39
|
schemaVersion: string;
|
|
40
40
|
changedFunctions: ChangedFunctionShape[];
|
package/dist/providers/config.js
CHANGED
|
@@ -78,9 +78,10 @@ export function builtinConfig() {
|
|
|
78
78
|
// ponytail: no complexityCmd — createGenericCommandProvider returns null for
|
|
79
79
|
// an entry without one (genericCommand.ts:35), which is INTENDED: the csharp
|
|
80
80
|
// provider is composed by the registration branch at evidence.ts, not by a
|
|
81
|
-
// shell command. coverageFiles are LITERAL paths (acceptance item 11):
|
|
82
|
-
//
|
|
83
|
-
//
|
|
81
|
+
// shell command. coverageFiles are LITERAL paths (acceptance item 11): discovery tries
|
|
82
|
+
// exact literal via path.join + access(), then case-insensitive readdir
|
|
83
|
+
// fallback in candidate's dirname; only misses both paths silently. Glob
|
|
84
|
+
// entries stay inert (no consumer globs them).
|
|
84
85
|
// Deliberately EMPTY. A Coverlet artifact lands in a per-run
|
|
85
86
|
// `TestResults/<GUID>/` directory whose name vstest generates; no literal
|
|
86
87
|
// can name it, and the three plausible-looking candidates previously listed
|
package/dist/rules.d.ts
CHANGED
package/dist/rules.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Provenance for the rules lineage stage. Self tool version tracks package.json.
|
|
2
|
-
export const rulesProvenance = { tool: 'checkchange', version: '0.
|
|
2
|
+
export const rulesProvenance = { tool: 'checkchange', version: '0.5.0' };
|
|
3
3
|
/**
|
|
4
4
|
* Evaluate changed functions against the high-CRAP rule.
|
|
5
5
|
* @param changed Array of changed functions
|