checkchange 0.4.4 → 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 +48 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +3 -4
- package/dist/complexity-providers/csharpDescriptorProvider.js +2 -2
- 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/rules.d.ts +1 -1
- package/dist/rules.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
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/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
|