checkchange 0.5.3 → 0.5.4

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.
@@ -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. `pnpm vitest run --coverage` → `coverage/coverage-final.json` (or jest coverage) — required before check
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
- - Threshold: default 30 via `--crap-threshold <n>`.
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}]}`.
@@ -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.3
177
+ // its tool is checkchange and its version is the package version — same 0.5.4
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.3';
180
+ const FALLBACK_TOOL_VERSION = '0.5.4';
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
@@ -1,5 +1,5 @@
1
1
  export declare const crapCalcProvenance: {
2
2
  readonly tool: "checkchange";
3
- readonly version: "0.5.3";
3
+ readonly version: "0.5.4";
4
4
  };
5
5
  export declare function calculateCrap(cc: number, coveragePercent: number | null): number | null;
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' style for the core package).
3
- export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.3' };
2
+ // (matches existing hard-coded '0.5.4' style for the core package).
3
+ export const crapCalcProvenance = { tool: 'checkchange', version: '0.5.4' };
4
4
  export function calculateCrap(cc, coveragePercent) {
5
5
  if (coveragePercent == null) {
6
6
  return null;
@@ -31,7 +31,7 @@ export interface DiagnosticLineageEntry {
31
31
  }
32
32
  export declare const evidenceProvenance: {
33
33
  readonly tool: "checkchange";
34
- readonly version: "0.5.3";
34
+ readonly version: "0.5.4";
35
35
  };
36
36
  export interface EvidenceOutput {
37
37
  schemaVersion: string;
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.3').
23
- export const evidenceProvenance = { tool: 'checkchange', version: '0.5.3' };
22
+ // Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.4').
23
+ export const evidenceProvenance = { tool: 'checkchange', version: '0.5.4' };
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];
@@ -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 results = out.ruleResults
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: [{ id: 'changed-function-high-crap' }],
52
+ rules,
32
53
  },
33
54
  },
34
55
  results,
@@ -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
@@ -1,7 +1,7 @@
1
1
  import { ChangedFunction } from './evidence.js';
2
2
  export declare const rulesProvenance: {
3
3
  readonly tool: "checkchange";
4
- readonly version: "0.5.3";
4
+ readonly version: "0.5.4";
5
5
  };
6
6
  export interface RuleResult {
7
7
  ruleId: string;
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.3' };
2
+ export const rulesProvenance = { tool: 'checkchange', version: '0.5.4' };
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",
3
+ "version": "0.5.4",
4
4
  "license": "MIT",
5
5
  "packageManager": "pnpm@11.17.0",
6
6
  "type": "module",