checkchange 0.5.3 → 0.5.5
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/.agents/skills/using-checkchange/SKILL.md +5 -2
- package/README.md +12 -1
- package/dist/auto-coverage.js +1 -1
- package/dist/complexity-providers/csharpDescriptorProvider.js +2 -2
- package/dist/crapCalc.d.ts +1 -1
- package/dist/crapCalc.js +2 -2
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +2 -2
- package/dist/formatters/index.d.ts +4 -0
- package/dist/formatters/sarif.js +23 -2
- package/dist/providers/config.js +13 -2
- package/dist/rules.d.ts +1 -1
- package/dist/rules.js +1 -1
- package/package.json +2 -1
|
@@ -17,7 +17,9 @@ Correct use of `checkchange check`: prevents hallucination, enforces WARN blocks
|
|
|
17
17
|
- Comparing evidence runs with `delta`.
|
|
18
18
|
|
|
19
19
|
# What It Entails
|
|
20
|
-
1.
|
|
20
|
+
1. Generate coverage artifact before check — required before check:
|
|
21
|
+
- vitest/jest: `pnpm vitest run --coverage` → `coverage/coverage-final.json`
|
|
22
|
+
- bun: `bun test --coverage --coverage-reporter=lcov` → `coverage/lcov.info`, check with `--coverage-file coverage/lcov.info`. Bare `bun test --coverage` prints a table + exit 0 but writes NO artifact (default reporter text) → `coverageArtifact: absent`. No converter needed. vitest cannot run `bun:test` suites — don't try it. (checkchange >=0.5.4 detects bun via builtin BUN_RUNNER + `--auto-coverage`.)
|
|
21
23
|
2. `checkchange check [--base <ref>] [--json] [--cache] [--auto-coverage] [--crap-threshold <n>] [--coverage-file <path>] [--format github|junit|sarif] [--provider-config <path>] [--allow-external-config] [--verbose]` — auto-detects base if omitted (origin/HEAD → origin/master/main → master/main)
|
|
22
24
|
3. Read gate + changedFunctions
|
|
23
25
|
|
|
@@ -57,7 +59,8 @@ Correct use of `checkchange check`: prevents hallucination, enforces WARN blocks
|
|
|
57
59
|
- Cache: `--cache` opt-in (default off). Also `CHECKCHANGE_CACHE=1` env.
|
|
58
60
|
- Format: `--format github|junit|sarif` (sidecar, separate from --json). Valid only on `check`. SARIF sidecar emits canonical `$schema` key (`https://json.schemastore.org/sarif-2.1.0.json`) since 0.5.1 — strict SARIF validators accept it.
|
|
59
61
|
- Value flags: inline (`--base=HEAD`) and next-token (`--base HEAD`) both honored; bare or empty-inline (`--base`, `--base=`) errors `<flag> requires a value`; `--crap-threshold abc` errors instead of producing NaN.
|
|
60
|
-
-
|
|
62
|
+
- Bun projects: `bun test --coverage --coverage-reporter=lcov` then `checkchange check --coverage-file coverage/lcov.info --json`. lcov provider reads `DA:` line-hit records, ignores `FN:` (bun emits none).
|
|
63
|
+
- Gate self-disable trap: a diff containing unsupported-extension files (e.g. package-lock.json, reformatted package.json) can make checkchange evaluate 0 functions → gate NOT_EVALUATED with gateReason no-supported-file-extensions. Keep such files out of the diff.
|
|
61
64
|
- Exit codes: FAILED→1, SUCCESS+WARN→1, UNSUPPORTED+NOT_APPLICABLE→0.
|
|
62
65
|
- Malformed artifact: analysisStatus=FAILED, gate=FAILED, completeness=INCOMPLETE.
|
|
63
66
|
- Trace sidecar: `{command:"trace", correlationId, spans:[{stage,durationMs,status}]}`.
|
package/README.md
CHANGED
|
@@ -209,6 +209,17 @@ You can also run the project's own test suite with:
|
|
|
209
209
|
pnpm exec vitest run --coverage
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
+
For Bun test projects:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
bun test --coverage --coverage-reporter=lcov
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This writes `coverage/lcov.info`, which CheckChange reads directly (it can also
|
|
219
|
+
run this command for you via `--auto-coverage`). Bare `bun test --coverage`
|
|
220
|
+
prints a coverage table but writes **no** artifact on disk; the
|
|
221
|
+
`--coverage-reporter=lcov` flag is required.
|
|
222
|
+
|
|
212
223
|
---
|
|
213
224
|
|
|
214
225
|
# Basic usage
|
|
@@ -268,7 +279,7 @@ Some of the most useful options are:
|
|
|
268
279
|
| `--format <github\|junit\|sarif>` | CI output format | none |
|
|
269
280
|
| `--json` | Produce machine-readable evidence | off |
|
|
270
281
|
| `--verbose` | Show additional diagnostics | off |
|
|
271
|
-
| `--auto-coverage` | Attempt automatic coverage setup | off |
|
|
282
|
+
| `--auto-coverage` | Attempt automatic coverage setup (vitest, jest, pytest, dotnet, or bun) | off |
|
|
272
283
|
|
|
273
284
|
Flags are per-command: `checkchange check --help` lists `--format`, `--base`,
|
|
274
285
|
`--json`; every subcommand lists its own flags. Unknown flags are rejected
|
package/dist/auto-coverage.js
CHANGED
|
@@ -75,7 +75,7 @@ export function autoCoverage(cwd) {
|
|
|
75
75
|
// (DOTNET_RUNNER, src/providers/config.ts:90) — it was missing, and C# repos
|
|
76
76
|
// were told to install a JS/Python toolchain they do not use. It also does not
|
|
77
77
|
// promise Roslyn complexity analysis: --auto-coverage drives COVERAGE only.
|
|
78
|
-
return { generatedPath: null, hint: 'No test runner detected. Install vitest, jest, or pytest, or add a .NET project (.csproj/.sln) so `dotnet test --collect:XPlat Code Coverage` is used, to use --auto-coverage.' };
|
|
78
|
+
return { generatedPath: null, hint: 'No test runner detected. Install vitest, jest, or pytest, or add a .NET project (.csproj/.sln) so `dotnet test --collect:XPlat Code Coverage` is used, or install Bun (`bun` on PATH or a `bunfig.toml`), to use --auto-coverage.' };
|
|
79
79
|
}
|
|
80
80
|
const fullCommand = [runner.command, ...runner.args];
|
|
81
81
|
const isBuiltinRunner = builtinConfig().providers.some(({ testRunners }) => testRunners?.some(({ command }) => command.length === fullCommand.length && command.every((arg, index) => arg === fullCommand[index])));
|
|
@@ -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.5.
|
|
177
|
+
// its tool is checkchange and its version is the package version — same 0.5.5
|
|
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.5.
|
|
180
|
+
const FALLBACK_TOOL_VERSION = '0.5.5';
|
|
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
|
-
// (matches existing hard-coded '0.5.
|
|
3
|
-
export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.
|
|
2
|
+
// (matches existing hard-coded '0.5.5' style for the core package).
|
|
3
|
+
export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.5' };
|
|
4
4
|
export function calculateCrap(cc, coveragePercent) {
|
|
5
5
|
if (coveragePercent == null) {
|
|
6
6
|
return null;
|
package/dist/evidence.d.ts
CHANGED
package/dist/evidence.js
CHANGED
|
@@ -19,8 +19,8 @@ import * as fs from 'fs';
|
|
|
19
19
|
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
|
-
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.
|
|
23
|
-
export const evidenceProvenance = { tool: 'checkchange', version: '0.5.
|
|
22
|
+
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.5').
|
|
23
|
+
export const evidenceProvenance = { tool: 'checkchange', version: '0.5.5' };
|
|
24
24
|
function sha256Hex(content) {
|
|
25
25
|
return createHash('sha256').update(content).digest('hex');
|
|
26
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FunctionCoverageDiagnosticEntry } from '../evidence.js';
|
|
1
2
|
/**
|
|
2
3
|
* Formatters are pure sidecars: (EvidenceOutputShape, opts) => string.
|
|
3
4
|
* They never call engine code and never emit absolute paths — file paths are
|
|
@@ -39,6 +40,9 @@ export interface EvidenceOutputShape {
|
|
|
39
40
|
schemaVersion: string;
|
|
40
41
|
changedFunctions: ChangedFunctionShape[];
|
|
41
42
|
ruleResults: RuleResultShape[];
|
|
43
|
+
diagnostics?: {
|
|
44
|
+
functionCoverage?: FunctionCoverageDiagnosticEntry[];
|
|
45
|
+
};
|
|
42
46
|
}
|
|
43
47
|
export declare const FORMATS: readonly ["github", "junit", "sarif"];
|
|
44
48
|
export type FormatType = (typeof FORMATS)[number];
|
package/dist/formatters/sarif.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** SARIF 2.1.0: one result per WARN with verbatim relative uri + line region. */
|
|
2
2
|
export function formatSARIF(out, opts) {
|
|
3
3
|
void opts;
|
|
4
|
-
const
|
|
4
|
+
const warnResults = out.ruleResults
|
|
5
5
|
.map((r, i) => ({ r, fn: out.changedFunctions[i] }))
|
|
6
6
|
.filter(({ r }) => r.result === 'WARN')
|
|
7
7
|
.map(({ r, fn }) => ({
|
|
@@ -17,6 +17,27 @@ export function formatSARIF(out, opts) {
|
|
|
17
17
|
],
|
|
18
18
|
message: { text: `${r.method} CRAP ${r.crap} > ${r.threshold} (cc ${r.cc}, cov ${r.coverage})` },
|
|
19
19
|
}));
|
|
20
|
+
// FN/FNDA: informational note results when diagnostics carry function coverage.
|
|
21
|
+
const coverageEntries = out.diagnostics?.functionCoverage ?? [];
|
|
22
|
+
const results = [
|
|
23
|
+
...warnResults,
|
|
24
|
+
...coverageEntries.map((entry) => ({
|
|
25
|
+
ruleId: 'function-hit-coverage',
|
|
26
|
+
level: 'note',
|
|
27
|
+
locations: [
|
|
28
|
+
{
|
|
29
|
+
physicalLocation: {
|
|
30
|
+
artifactLocation: { uri: entry.file },
|
|
31
|
+
region: { startLine: entry.line, endLine: entry.line },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
message: { text: `${entry.method} FN hits ${entry.hits}` },
|
|
36
|
+
})),
|
|
37
|
+
];
|
|
38
|
+
const rules = coverageEntries.length > 0
|
|
39
|
+
? [{ id: 'changed-function-high-crap' }, { id: 'function-hit-coverage' }]
|
|
40
|
+
: [{ id: 'changed-function-high-crap' }];
|
|
20
41
|
return JSON.stringify({
|
|
21
42
|
// SARIF 2.1.0 top-level schema key is `$schema`; the schemastore schema
|
|
22
43
|
// has additionalProperties:false, so `schema` would make the doc invalid.
|
|
@@ -28,7 +49,7 @@ export function formatSARIF(out, opts) {
|
|
|
28
49
|
driver: {
|
|
29
50
|
name: 'checkchange',
|
|
30
51
|
version: out.schemaVersion,
|
|
31
|
-
rules
|
|
52
|
+
rules,
|
|
32
53
|
},
|
|
33
54
|
},
|
|
34
55
|
results,
|
package/dist/providers/config.js
CHANGED
|
@@ -20,6 +20,17 @@ const JEST_RUNNER = {
|
|
|
20
20
|
command: ['npx', 'jest', '--coverage'],
|
|
21
21
|
artifact: 'coverage/coverage-final.json',
|
|
22
22
|
};
|
|
23
|
+
// Probe `bun --version` (spawned as `bun --version --version`), NOT `bun test --version`:
|
|
24
|
+
// measured on bun 1.3.14, the latter prints the banner then RUNS THE SUITE and exits
|
|
25
|
+
// non-zero on no/failing tests — a probe must not execute tests. Bare `bun test
|
|
26
|
+
// --coverage` writes NO artifact (default reporter 'text'); lcov is required.
|
|
27
|
+
const BUN_RUNNER = {
|
|
28
|
+
name: 'bun',
|
|
29
|
+
configFiles: ['bunfig.toml'],
|
|
30
|
+
binaryProbes: ['bun --version'],
|
|
31
|
+
command: ['bun', 'test', '--coverage', '--coverage-reporter=lcov'],
|
|
32
|
+
artifact: 'coverage/lcov.info',
|
|
33
|
+
};
|
|
23
34
|
const PYTEST_RUNNER = {
|
|
24
35
|
name: 'pytest',
|
|
25
36
|
configFiles: ['pyproject.toml', 'pytest.ini', 'setup.cfg', 'requirements.txt'],
|
|
@@ -58,13 +69,13 @@ export function builtinConfig() {
|
|
|
58
69
|
language: 'javascript',
|
|
59
70
|
extensions: ['.js', '.jsx', '.mjs', '.cjs'],
|
|
60
71
|
coverageFiles: ['coverage/coverage-final.json', 'coverage/lcov.info'],
|
|
61
|
-
testRunners: [VITEST_RUNNER, JEST_RUNNER],
|
|
72
|
+
testRunners: [VITEST_RUNNER, JEST_RUNNER, BUN_RUNNER],
|
|
62
73
|
},
|
|
63
74
|
{
|
|
64
75
|
language: 'typescript',
|
|
65
76
|
extensions: ['.ts', '.tsx'],
|
|
66
77
|
coverageFiles: ['coverage/coverage-final.json', 'coverage/lcov.info'],
|
|
67
|
-
testRunners: [VITEST_RUNNER, JEST_RUNNER],
|
|
78
|
+
testRunners: [VITEST_RUNNER, JEST_RUNNER, BUN_RUNNER],
|
|
68
79
|
},
|
|
69
80
|
{
|
|
70
81
|
language: 'python',
|
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.5.
|
|
2
|
+
export const rulesProvenance = { tool: 'checkchange', version: '0.5.5' };
|
|
3
3
|
/**
|
|
4
4
|
* Evaluate changed functions against the high-CRAP rule.
|
|
5
5
|
* @param changed Array of changed functions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkchange",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"packageManager": "pnpm@11.17.0",
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
13
13
|
".agents/skills/using-checkchange/SKILL.md",
|
|
14
|
+
"README.md",
|
|
14
15
|
"!dist/**/*.test.*"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|