checkchange 0.4.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/LICENSE +21 -0
- package/README.md +150 -0
- package/dist/attribution.d.ts +19 -0
- package/dist/attribution.js +175 -0
- package/dist/auto-coverage.d.ts +8 -0
- package/dist/auto-coverage.js +93 -0
- package/dist/cache.d.ts +70 -0
- package/dist/cache.js +458 -0
- package/dist/cli.d.ts +51 -0
- package/dist/cli.js +810 -0
- package/dist/complexity-providers/pythonASTComplexityProvider.d.ts +9 -0
- package/dist/complexity-providers/pythonASTComplexityProvider.js +148 -0
- package/dist/complexity-providers/pythonDescriptorProvider.d.ts +17 -0
- package/dist/complexity-providers/pythonDescriptorProvider.js +119 -0
- package/dist/complexity-providers.d.ts +6 -0
- package/dist/complexity-providers.js +1 -0
- package/dist/complexity.d.ts +14 -0
- package/dist/complexity.js +75 -0
- package/dist/coverage-providers/lcovProvider.d.ts +12 -0
- package/dist/coverage-providers/lcovProvider.js +126 -0
- package/dist/coverage.d.ts +28 -0
- package/dist/coverage.js +451 -0
- package/dist/crap.d.ts +31 -0
- package/dist/crap.js +84 -0
- package/dist/crapCalc.d.ts +5 -0
- package/dist/crapCalc.js +11 -0
- package/dist/delta.d.ts +100 -0
- package/dist/delta.js +214 -0
- package/dist/evidence.d.ts +201 -0
- package/dist/evidence.js +906 -0
- package/dist/execute.d.ts +59 -0
- package/dist/execute.js +92 -0
- package/dist/formatters/github.d.ts +5 -0
- package/dist/formatters/github.js +27 -0
- package/dist/formatters/index.d.ts +47 -0
- package/dist/formatters/index.js +14 -0
- package/dist/formatters/junit.d.ts +5 -0
- package/dist/formatters/junit.js +32 -0
- package/dist/formatters/sarif.d.ts +5 -0
- package/dist/formatters/sarif.js +35 -0
- package/dist/fs-safety.d.ts +10 -0
- package/dist/fs-safety.js +47 -0
- package/dist/git.d.ts +50 -0
- package/dist/git.js +137 -0
- package/dist/help.d.ts +40 -0
- package/dist/help.js +274 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/providers/config.d.ts +41 -0
- package/dist/providers/config.js +172 -0
- package/dist/providers/genericCommand.d.ts +3 -0
- package/dist/providers/genericCommand.js +89 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/prepare.d.ts +124 -0
- package/dist/providers/prepare.js +459 -0
- package/dist/providers/runner-detection.d.ts +30 -0
- package/dist/providers/runner-detection.js +207 -0
- package/dist/rules.d.ts +27 -0
- package/dist/rules.js +54 -0
- package/package.json +52 -0
package/dist/delta.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { openWithinRoot } from './fs-safety.js';
|
|
3
|
+
const MAX_SIZE = 100 * 1024 * 1024; // 100MB, mirrors lcovProvider.ts:11
|
|
4
|
+
/** Identity key: file:method:lineStart (src/evidence.ts:138 buildFingerprints). */
|
|
5
|
+
function keyFor(f) {
|
|
6
|
+
return `${f.file}:${f.method}:${f.lineStart}`;
|
|
7
|
+
}
|
|
8
|
+
function deltaOf(base, cur) {
|
|
9
|
+
// null vs 0 distinguished (INV-01, evidence-contract.md:159-161):
|
|
10
|
+
// null on either side means "no evidence", not zero -> delta is null.
|
|
11
|
+
if (base === null || cur === null)
|
|
12
|
+
return null;
|
|
13
|
+
return cur - base;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Rule results keyed by file:method (RuleResult has no lineStart). Stores
|
|
17
|
+
* ordered arrays per key, pushed in input order. Overloaded methods (same
|
|
18
|
+
* file+method, different lineStart) collide on the key; positional
|
|
19
|
+
* alignment resolves them: the i-th function visited in a group
|
|
20
|
+
* (sorted-key order) is assigned the i-th rule (input order). Single
|
|
21
|
+
* ruleId today (src/rules.ts:7), so within a group rules share ruleId
|
|
22
|
+
* and differ only by result. Deterministic because input order is
|
|
23
|
+
* deterministic per evidence contract. If rules run out for a group,
|
|
24
|
+
* ruleResult is undefined (transition null).
|
|
25
|
+
*/
|
|
26
|
+
function ruleResultMap(results) {
|
|
27
|
+
const m = new Map();
|
|
28
|
+
for (const r of results) {
|
|
29
|
+
const k = `${r.file}:${r.method}`;
|
|
30
|
+
const arr = m.get(k);
|
|
31
|
+
if (arr)
|
|
32
|
+
arr.push(r);
|
|
33
|
+
else
|
|
34
|
+
m.set(k, [r]);
|
|
35
|
+
}
|
|
36
|
+
return m;
|
|
37
|
+
}
|
|
38
|
+
function transitionOf(base, cur) {
|
|
39
|
+
if (base === undefined || cur === undefined || base === cur)
|
|
40
|
+
return null;
|
|
41
|
+
return `${base}->${cur}`;
|
|
42
|
+
}
|
|
43
|
+
/** Trim lineage inputs: replace absolute-path string values with basename. */
|
|
44
|
+
function trimLineage(lineage) {
|
|
45
|
+
if (!lineage)
|
|
46
|
+
return null;
|
|
47
|
+
return lineage.map((e) => ({
|
|
48
|
+
stage: e.stage,
|
|
49
|
+
tool: e.tool,
|
|
50
|
+
version: e.version,
|
|
51
|
+
inputs: Object.fromEntries(Object.entries(e.inputs ?? {}).map(([k, v]) => [
|
|
52
|
+
k,
|
|
53
|
+
typeof v === 'string' && path.isAbsolute(v) ? path.basename(v) : v,
|
|
54
|
+
])),
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/** Pure comparator: no I/O, deterministic (all output arrays sorted by key). */
|
|
58
|
+
export function compareEvidenceOutputs(baseline, current) {
|
|
59
|
+
const baseByKey = new Map();
|
|
60
|
+
for (const f of baseline.changedFunctions ?? [])
|
|
61
|
+
baseByKey.set(keyFor(f), f);
|
|
62
|
+
const curByKey = new Map();
|
|
63
|
+
for (const f of current.changedFunctions ?? [])
|
|
64
|
+
curByKey.set(keyFor(f), f);
|
|
65
|
+
const baseRules = ruleResultMap(baseline.ruleResults ?? []);
|
|
66
|
+
const curRules = ruleResultMap(current.ruleResults ?? []);
|
|
67
|
+
const baseFp = baseline.diagnostics?.fingerprints;
|
|
68
|
+
const curFp = current.diagnostics?.fingerprints;
|
|
69
|
+
const added = [];
|
|
70
|
+
const removed = [];
|
|
71
|
+
const changed = [];
|
|
72
|
+
const unchanged = [];
|
|
73
|
+
// Positional rule consumption counters: within each file:method group,
|
|
74
|
+
// the i-th function visited (sorted-key order) gets the i-th rule
|
|
75
|
+
// (input order). See ruleResultMap doc comment.
|
|
76
|
+
const baseRuleIdx = new Map();
|
|
77
|
+
const curRuleIdx = new Map();
|
|
78
|
+
const allKeys = [...new Set([...baseByKey.keys(), ...curByKey.keys()])].sort();
|
|
79
|
+
for (const key of allKeys) {
|
|
80
|
+
const b = baseByKey.get(key);
|
|
81
|
+
const c = curByKey.get(key);
|
|
82
|
+
// Derive ruleKey from object fields, not string split — file paths or
|
|
83
|
+
// methods containing ':' (e.g. 'a:b.ts') would mis-split the identity key.
|
|
84
|
+
const f = b ?? c;
|
|
85
|
+
const ruleKey = f ? `${f.file}:${f.method}` : '';
|
|
86
|
+
// Consume rule positionally. Counters increment for every function in
|
|
87
|
+
// the group (including unchanged) to preserve alignment.
|
|
88
|
+
const bi = b ? (baseRuleIdx.get(ruleKey) ?? 0) : 0;
|
|
89
|
+
if (b)
|
|
90
|
+
baseRuleIdx.set(ruleKey, bi + 1);
|
|
91
|
+
const ci = c ? (curRuleIdx.get(ruleKey) ?? 0) : 0;
|
|
92
|
+
if (c)
|
|
93
|
+
curRuleIdx.set(ruleKey, ci + 1);
|
|
94
|
+
const baseRR = b ? baseRules.get(ruleKey)?.[bi] : undefined;
|
|
95
|
+
const curRR = c ? curRules.get(ruleKey)?.[ci] : undefined;
|
|
96
|
+
if (!b && c) {
|
|
97
|
+
added.push({ key, current: c, ...(curRR ? { ruleResult: curRR } : {}) });
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (b && !c) {
|
|
101
|
+
removed.push({ key, baseline: b, ...(baseRR ? { ruleResult: baseRR } : {}) });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (!b || !c)
|
|
105
|
+
continue;
|
|
106
|
+
const fpB = baseFp?.[key];
|
|
107
|
+
const fpC = curFp?.[key];
|
|
108
|
+
let fingerprintChanged = false;
|
|
109
|
+
let isChanged;
|
|
110
|
+
if (fpB !== undefined && fpC !== undefined) {
|
|
111
|
+
fingerprintChanged = fpB !== fpC;
|
|
112
|
+
isChanged = fingerprintChanged;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Pre-0.5 artifacts lack fingerprints: degrade to field comparison.
|
|
116
|
+
isChanged =
|
|
117
|
+
b.cc !== c.cc || b.crap !== c.crap || b.coverage !== c.coverage || b.lineEnd !== c.lineEnd;
|
|
118
|
+
}
|
|
119
|
+
if (!isChanged) {
|
|
120
|
+
unchanged.push(key);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
changed.push({
|
|
124
|
+
key,
|
|
125
|
+
baseline: b,
|
|
126
|
+
current: c,
|
|
127
|
+
fingerprintChanged,
|
|
128
|
+
deltas: {
|
|
129
|
+
cc: deltaOf(b.cc, c.cc),
|
|
130
|
+
crap: deltaOf(b.crap, c.crap),
|
|
131
|
+
coverage: deltaOf(b.coverage, c.coverage),
|
|
132
|
+
},
|
|
133
|
+
ruleTransition: transitionOf(baseRR?.result, curRR?.result),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const gateTransition = baseline.gate === current.gate ? null : `${baseline.gate}->${current.gate}`;
|
|
137
|
+
const completenessTransition = baseline.completeness === current.completeness
|
|
138
|
+
? null
|
|
139
|
+
: `${baseline.completeness}->${current.completeness}`;
|
|
140
|
+
const hasProvenance = baseline.diagnostics !== undefined || current.diagnostics !== undefined;
|
|
141
|
+
return {
|
|
142
|
+
command: 'delta',
|
|
143
|
+
schemaVersion: '0.5',
|
|
144
|
+
inputs: {
|
|
145
|
+
baseline: {
|
|
146
|
+
base: baseline.analysis.base,
|
|
147
|
+
analysisStatus: baseline.analysisStatus,
|
|
148
|
+
gate: baseline.gate,
|
|
149
|
+
changedFunctions: baseByKey.size,
|
|
150
|
+
},
|
|
151
|
+
current: {
|
|
152
|
+
base: current.analysis.base,
|
|
153
|
+
analysisStatus: current.analysisStatus,
|
|
154
|
+
gate: current.gate,
|
|
155
|
+
changedFunctions: curByKey.size,
|
|
156
|
+
},
|
|
157
|
+
thresholds: {
|
|
158
|
+
baseline: baseline.policy.crapThreshold,
|
|
159
|
+
current: current.policy.crapThreshold,
|
|
160
|
+
equal: baseline.policy.crapThreshold === current.policy.crapThreshold,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
summary: {
|
|
164
|
+
added: added.length,
|
|
165
|
+
removed: removed.length,
|
|
166
|
+
changed: changed.length,
|
|
167
|
+
unchanged: unchanged.length,
|
|
168
|
+
gateTransition,
|
|
169
|
+
completenessTransition,
|
|
170
|
+
},
|
|
171
|
+
functions: { added, removed, changed, unchanged },
|
|
172
|
+
...(hasProvenance
|
|
173
|
+
? {
|
|
174
|
+
provenance: {
|
|
175
|
+
baseline: {
|
|
176
|
+
lineage: trimLineage(baseline.diagnostics?.lineage),
|
|
177
|
+
quality: baseline.diagnostics?.quality ?? null,
|
|
178
|
+
},
|
|
179
|
+
current: {
|
|
180
|
+
lineage: trimLineage(current.diagnostics?.lineage),
|
|
181
|
+
quality: current.diagnostics?.quality ?? null,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
: {}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** File-pair mode: read one artifact through the shared fail-closed seam. */
|
|
189
|
+
async function readEvidenceFile(filePath, cwd) {
|
|
190
|
+
const handle = await openWithinRoot(cwd, filePath).catch((error) => {
|
|
191
|
+
if (error instanceof Error && error.message.startsWith('openWithinRoot: candidate escapes root')) {
|
|
192
|
+
throw new Error(`delta: input path escapes cwd: ${filePath}`);
|
|
193
|
+
}
|
|
194
|
+
throw error;
|
|
195
|
+
});
|
|
196
|
+
try {
|
|
197
|
+
const stats = await handle.stat();
|
|
198
|
+
if (stats.size > MAX_SIZE) {
|
|
199
|
+
throw new Error(`delta: input exceeds maximum allowed size of ${MAX_SIZE} bytes: ${filePath}`);
|
|
200
|
+
}
|
|
201
|
+
return JSON.parse(await handle.readFile('utf8'));
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
await handle.close().catch(() => undefined);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** File-pair mode: read two EvidenceOutput JSON files with guards, compare. */
|
|
208
|
+
export async function compareFromFiles(baselinePath, currentPath, cwd = process.cwd()) {
|
|
209
|
+
const [baseline, current] = await Promise.all([
|
|
210
|
+
readEvidenceFile(baselinePath, cwd),
|
|
211
|
+
readEvidenceFile(currentPath, cwd),
|
|
212
|
+
]);
|
|
213
|
+
return compareEvidenceOutputs(baseline, current);
|
|
214
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { type RuleResult } from './rules.js';
|
|
2
|
+
import { type CoverageResult } from './coverage.js';
|
|
3
|
+
import { type AttributedComplexity } from './attribution.js';
|
|
4
|
+
import { type ComplexityInfo } from './complexity.js';
|
|
5
|
+
import { type TraceRun } from './execute.js';
|
|
6
|
+
import { type MethodEvidence } from './crap.js';
|
|
7
|
+
import { type ResolvedProvider, type ProviderConfig } from './providers/index.js';
|
|
8
|
+
/** Capabilities passed to buildOutput / buildEvidenceOutput. */
|
|
9
|
+
export interface Capabilities {
|
|
10
|
+
git: string;
|
|
11
|
+
crapTypescript?: string;
|
|
12
|
+
complexity?: string;
|
|
13
|
+
coverageArtifact?: string;
|
|
14
|
+
[key: string]: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Source provenance for a method evidence entry. */
|
|
17
|
+
export interface Source {
|
|
18
|
+
tool: string;
|
|
19
|
+
version: string;
|
|
20
|
+
}
|
|
21
|
+
/** MethodEvidence extended with source (source is untyped in crap.ts). */
|
|
22
|
+
export interface MethodEvidenceWithSource extends MethodEvidence {
|
|
23
|
+
source?: Source;
|
|
24
|
+
}
|
|
25
|
+
export type LineageStage = 'git' | 'complexity' | 'coverage' | 'attribution' | 'crapCalc' | 'rules' | 'evidence';
|
|
26
|
+
export interface DiagnosticLineageEntry {
|
|
27
|
+
stage: LineageStage;
|
|
28
|
+
tool: string;
|
|
29
|
+
version: string;
|
|
30
|
+
inputs: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export declare const evidenceProvenance: {
|
|
33
|
+
readonly tool: "checkchange";
|
|
34
|
+
readonly version: "0.4.0";
|
|
35
|
+
};
|
|
36
|
+
export interface EvidenceOutput {
|
|
37
|
+
schemaVersion: string;
|
|
38
|
+
analysis: {
|
|
39
|
+
base: string;
|
|
40
|
+
target: string;
|
|
41
|
+
};
|
|
42
|
+
capabilities: {
|
|
43
|
+
git: string;
|
|
44
|
+
complexity: string;
|
|
45
|
+
coverageArtifact: string;
|
|
46
|
+
};
|
|
47
|
+
changedFunctions: ChangedFunction[];
|
|
48
|
+
policy: {
|
|
49
|
+
crapThreshold: number;
|
|
50
|
+
};
|
|
51
|
+
ruleResults: RuleResult[];
|
|
52
|
+
analysisStatus: string;
|
|
53
|
+
gate: string | null;
|
|
54
|
+
completeness: string;
|
|
55
|
+
coverageErrorReason?: string;
|
|
56
|
+
diagnostics?: {
|
|
57
|
+
lineage: DiagnosticLineageEntry[];
|
|
58
|
+
quality: DiagnosticQuality;
|
|
59
|
+
fingerprints?: Record<string, string> | undefined;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export type QualityStage = 'git' | 'complexity' | 'coverage' | 'attribution' | 'rules';
|
|
63
|
+
export interface UncoveredFunction {
|
|
64
|
+
file: string;
|
|
65
|
+
method: string;
|
|
66
|
+
lineStart: number;
|
|
67
|
+
lineEnd: number;
|
|
68
|
+
}
|
|
69
|
+
export interface DiagnosticQuality {
|
|
70
|
+
coverage: 'DIRECT' | 'UNAVAILABLE';
|
|
71
|
+
complexity: 'NATIVE' | 'UNAVAILABLE';
|
|
72
|
+
/**
|
|
73
|
+
* Deterministic evidence score 0-100, closed-form arithmetic over evidence
|
|
74
|
+
* values only (no model judgment). Formula:
|
|
75
|
+
* completeness = Σ weights of completed stages
|
|
76
|
+
* (git 10 | complexity 20 | coverage 40 | attribution 20 | rules 10; total 100)
|
|
77
|
+
* coverageRatio = (# changed functions with coverage > 0) / (# changed functions); 1 when none
|
|
78
|
+
* score = round(0.7 * completeness + 0.3 * 100 * coverageRatio)
|
|
79
|
+
* score is null when coverage-backed analysis did not reach rule evaluation
|
|
80
|
+
* (no usable coverage evidence AT ALL). INV-01 ZERO≠NULL: a measured 0% is
|
|
81
|
+
* a number (lowers score), never null — null only when nothing was measured.
|
|
82
|
+
*/
|
|
83
|
+
score: number | null;
|
|
84
|
+
stageComplete: Record<QualityStage, boolean>;
|
|
85
|
+
uncoveredFunctions?: UncoveredFunction[];
|
|
86
|
+
}
|
|
87
|
+
export interface ProviderFactory {
|
|
88
|
+
collectComplexity: (cwd: string, trace?: TraceRun, changedFiles?: ReadonlySet<string>) => Promise<ComplexityInfo[]>;
|
|
89
|
+
readCoverage: (cwd: string, file?: string, trace?: TraceRun, autoGenerated?: boolean) => Promise<CoverageResult>;
|
|
90
|
+
}
|
|
91
|
+
export declare function registerProvider(ext: string, factory: ProviderFactory): void;
|
|
92
|
+
export declare function getProvider(ext: string): ProviderFactory | undefined;
|
|
93
|
+
/** Load provider config and populate providers Map. Call once at startup. */
|
|
94
|
+
export declare function initProviderConfig(explicitPath?: string, allowExternalConfig?: boolean): {
|
|
95
|
+
config: ProviderConfig;
|
|
96
|
+
registry: Map<string, ResolvedProvider>;
|
|
97
|
+
source: 'explicit' | 'repo-root' | 'builtin';
|
|
98
|
+
};
|
|
99
|
+
/** Extension priority list (derived from config). Lazily falls back to hardcoded defaults. */
|
|
100
|
+
export declare function extensionPriority(): readonly string[];
|
|
101
|
+
/** Supported extensions set (derived from config). Lazily falls back to hardcoded defaults. */
|
|
102
|
+
export declare function supportedExtensions(): Set<string>;
|
|
103
|
+
/** Loaded provider config (or null if not initialized). */
|
|
104
|
+
export declare function providerConfig(): ProviderConfig | null;
|
|
105
|
+
/** Loaded provider registry (or null if not initialized). */
|
|
106
|
+
export declare function providerRegistry(): Map<string, ResolvedProvider> | null;
|
|
107
|
+
/** Get the language for a file from the loaded registry. Falls back to hardcoded defaults. */
|
|
108
|
+
export declare function getLanguageForFile(filePath: string): string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Checks whether intervals contain only non-supported file types.
|
|
111
|
+
* Returns true only when intervals is non-empty AND every file has an unsupported extension.
|
|
112
|
+
* ponytail: extracted from buildEvidenceOutput to reduce cyclomatic complexity.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isUnsupportedIntervals(intervals: Map<string, {
|
|
115
|
+
start: number;
|
|
116
|
+
end: number;
|
|
117
|
+
}[]>): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Builds the coverage lineage inputs object (deterministic, no timing).
|
|
120
|
+
* Handles absolute path → relative conversion, absent coverage hash sentinel,
|
|
121
|
+
* and coverage quality vocabulary (DIRECT / UNAVAILABLE).
|
|
122
|
+
*/
|
|
123
|
+
export declare function buildCoverageLineageInputs(coverageFile: string | undefined, cwd: string, coverageResult: CoverageResult, errorReason: string | undefined): Record<string, unknown>;
|
|
124
|
+
export interface ChangedFunction {
|
|
125
|
+
file: string;
|
|
126
|
+
method: string;
|
|
127
|
+
lineStart: number;
|
|
128
|
+
lineEnd: number;
|
|
129
|
+
cc: number;
|
|
130
|
+
crap: number | null;
|
|
131
|
+
coverage: number | null;
|
|
132
|
+
coverageKind: string;
|
|
133
|
+
analyzerStatus: 'passed' | 'failed' | 'skipped';
|
|
134
|
+
source: Source;
|
|
135
|
+
language?: string;
|
|
136
|
+
framework?: string;
|
|
137
|
+
}
|
|
138
|
+
export declare function detectExtension(intervals: Map<string, {
|
|
139
|
+
start: number;
|
|
140
|
+
end: number;
|
|
141
|
+
}[]>): string;
|
|
142
|
+
export declare function computeGateAndCompleteness(ruleResults: RuleResult[]): {
|
|
143
|
+
gate: string;
|
|
144
|
+
completeness: string;
|
|
145
|
+
};
|
|
146
|
+
export declare function enrichWithLanguageAndFramework(changedFunctions: ChangedFunction[], cwd: string): ChangedFunction[];
|
|
147
|
+
export declare function readCoverageWithProvider(detectedExtension: string, cwd: string, coverageFile: string | undefined, trace: TraceRun | undefined, autoGenerated: boolean | undefined): Promise<{
|
|
148
|
+
result: CoverageResult;
|
|
149
|
+
capability: string;
|
|
150
|
+
errorReason: string | undefined;
|
|
151
|
+
elapsed: number;
|
|
152
|
+
}>;
|
|
153
|
+
export declare function mapToMethodEvidence(attributedComplexity: AttributedComplexity[]): MethodEvidenceWithSource[];
|
|
154
|
+
export declare function correlate(methodEvidence: MethodEvidenceWithSource[], intervals: Map<string, {
|
|
155
|
+
start: number;
|
|
156
|
+
end: number;
|
|
157
|
+
}[]>): {
|
|
158
|
+
file: string;
|
|
159
|
+
method: string;
|
|
160
|
+
lineStart: number;
|
|
161
|
+
lineEnd: number;
|
|
162
|
+
cc: number;
|
|
163
|
+
crap: number | null;
|
|
164
|
+
coverage: number | null;
|
|
165
|
+
coverageKind: string;
|
|
166
|
+
analyzerStatus: "skipped" | "failed" | "passed";
|
|
167
|
+
source: {
|
|
168
|
+
tool: string;
|
|
169
|
+
version: string;
|
|
170
|
+
};
|
|
171
|
+
}[];
|
|
172
|
+
/**
|
|
173
|
+
* Legacy buildOutput for WP3 tests (schema 0.1, sync). Kept for backward compatibility.
|
|
174
|
+
*/
|
|
175
|
+
export declare function buildOutput(base: string, changed: ChangedFunction[], threshold?: number, capabilities?: Capabilities): {
|
|
176
|
+
schemaVersion: string;
|
|
177
|
+
analysis: {
|
|
178
|
+
base: string;
|
|
179
|
+
target: string;
|
|
180
|
+
};
|
|
181
|
+
capabilities: Record<string, string>;
|
|
182
|
+
changedFunctions: ChangedFunction[];
|
|
183
|
+
policy: {
|
|
184
|
+
crapThreshold: number;
|
|
185
|
+
};
|
|
186
|
+
ruleResults: RuleResult[];
|
|
187
|
+
gate: string;
|
|
188
|
+
completeness: string;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Builds the final JSON output using composed evidence.
|
|
192
|
+
* @param base The base reference used for comparison
|
|
193
|
+
* @param intervals Map from file path to array of changed intervals (from git)
|
|
194
|
+
* @param cwd Current working directory
|
|
195
|
+
* @param threshold CRAP threshold for evaluating changed functions
|
|
196
|
+
* @returns Promise<OutputJson>
|
|
197
|
+
*/
|
|
198
|
+
export declare function buildEvidenceOutput(base: string, intervals: Map<string, {
|
|
199
|
+
start: number;
|
|
200
|
+
end: number;
|
|
201
|
+
}[]>, cwd: string, threshold?: number, coverageFile?: string, trace?: TraceRun, autoGenerated?: boolean): Promise<EvidenceOutput>;
|