checkchange 0.4.2 → 0.4.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.
@@ -27,6 +27,29 @@ const PYTEST_RUNNER = {
27
27
  command: ['python3', '-m', 'pytest', '--cov', '--cov-report=xml'],
28
28
  artifact: 'coverage.xml',
29
29
  };
30
+ // Coverlet ships in the `dotnet` SDK; the XPlat collector needs no extra package,
31
+ // hence no `install` (no builtin runner declares one — see PYTEST/JEST/VITEST).
32
+ // binaryProbes must be a COMMAND probe: probeRunner treats a space-free entry as a
33
+ // literal path (`fs.accessSync(path.join(cwd, bp))`, runner-detection.ts:148-156),
34
+ // so a bare `dotnet` could never match. Same shape as PYTEST's `python3 -m pytest`.
35
+ // ponytail: MEASURED (dotnet 9.0.121, coverlet.collector 6.0.4) — the XPlat
36
+ // collector always writes `TestResults/<guid>/coverage.cobertura.xml`. The GUID comes
37
+ // from vstest, not Coverlet, and `--results-directory` pins only the PARENT, so no
38
+ // literal can name it. Runsettings `<Output>` (relative AND absolute) and inline
39
+ // `Output=` are SILENTLY IGNORED — verified: artifact still landed in the GUID dir.
40
+ // Coverlet also exposes no `Output` knob at all (only `ReportFormat`). This `artifact`
41
+ // literal is therefore permanently INERT: no consumer globs. Real discovery works
42
+ // anyway, via two live paths — the TestResults scan in readCoverage (src/coverage.ts)
43
+ // and an explicit `--coverage-file <path>`. Both are measured green on a real repo
44
+ // (auto-detect, no flag, no config change). Do not "fix" this with a glob: globs are
45
+ // inert in every coverage consumer — see Task 4 acceptance item 11.
46
+ const DOTNET_RUNNER = {
47
+ name: 'dotnet',
48
+ configFiles: ['*.csproj', '*.sln'],
49
+ binaryProbes: ['dotnet --version'],
50
+ command: ['dotnet', 'test', '--collect:XPlat Code Coverage'],
51
+ artifact: 'TestResults/coverage.cobertura.xml',
52
+ };
30
53
  export function builtinConfig() {
31
54
  return {
32
55
  version: 1,
@@ -49,6 +72,27 @@ export function builtinConfig() {
49
72
  coverageFiles: ['.coverage', 'coverage.xml', 'coverage.json', 'coverage/coverage-final.json'],
50
73
  testRunners: [PYTEST_RUNNER],
51
74
  },
75
+ {
76
+ language: 'csharp',
77
+ extensions: ['.cs'],
78
+ // ponytail: no complexityCmd — createGenericCommandProvider returns null for
79
+ // an entry without one (genericCommand.ts:35), which is INTENDED: the csharp
80
+ // provider is composed by the registration branch at evidence.ts, not by a
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).
85
+ // Deliberately EMPTY. A Coverlet artifact lands in a per-run
86
+ // `TestResults/<GUID>/` directory whose name vstest generates; no literal
87
+ // can name it, and the three plausible-looking candidates previously listed
88
+ // here were never observed on disk. Discovery is the automatic TestResults
89
+ // scan in src/coverage.ts (scanCoberturaUnderTestResults) plus an explicit
90
+ // `--coverage-file`. Adding unverifiable paths here would be worse than a
91
+ // recorded gap: an entry that misses is silently skipped, so it buys nothing
92
+ // and misleads the next reader about what was actually tested.
93
+ coverageFiles: [],
94
+ testRunners: [DOTNET_RUNNER],
95
+ },
52
96
  ],
53
97
  };
54
98
  }
@@ -121,6 +121,7 @@ export interface VerifyReport {
121
121
  * (a) Node import probe: `@barney-media/crap-typescript-core` resolvable
122
122
  * (b) CLI version probe: `npx --no-install crap-typescript --version` exit 0
123
123
  * (c) Python stdlib probe: venv-aware `python -c "import ast"`
124
+ * (d) .NET SDK probe: `dotnet --version` exit 0
124
125
  * Returns re-detected stack, per-probe status, and aggregate `ok`.
125
126
  */
126
127
  export declare function verifyInstall(stack: DetectedStack, options: PrepareOptions): Promise<VerifyReport>;
@@ -71,6 +71,18 @@ function packageManagerCommand(lockfile, language) {
71
71
  }
72
72
  if (language === 'python')
73
73
  return ['pip', 'install'];
74
+ // csharp returns null ON PURPOSE. `dotnet restore` takes a PROJECT OR SOLUTION,
75
+ // never package names — spreading declared packages onto it is
76
+ // `dotnet restore Crap4DotNet`, which is MSB1009 "Project file does not exist",
77
+ // i.e. an install action that can NEVER succeed. Cycle 1 did exactly that (this
78
+ // branch returned ['dotnet','restore'] and the caller appended the packages).
79
+ // C# packages are .NET GLOBAL TOOLS, so buildInstallPlan emits a per-package
80
+ // `dotnet tool install -g <pkg>` action for each one instead. Returning null here
81
+ // makes MSB1009 unreachable BY CONSTRUCTION: no package id can reach a restore
82
+ // verb, because no restore verb is ever produced for csharp. The Roslyn vehicle
83
+ // id stays a csharpDescriptorProvider secret (SD-2/SD-5).
84
+ if (language === 'csharp')
85
+ return null;
74
86
  return null;
75
87
  }
76
88
  /** Derive a --version probe from the runner's command. */
@@ -117,14 +129,33 @@ export function createInstallPlan(stack, registry, config, cwd) {
117
129
  }
118
130
  // install-lockfile: install packages via lockfile-precedence package manager
119
131
  if (packages.length > 0) {
120
- const pmCmd = packageManagerCommand(lockfile, lang);
121
- if (pmCmd) {
122
- actions.push({
123
- kind: 'install-lockfile',
124
- command: [...pmCmd, ...packages],
125
- packages,
126
- description: `Install ${packages.join(', ')} via ${pmCmd[0]}`,
127
- });
132
+ if (lang === 'csharp') {
133
+ // ONE action PER package: `dotnet tool install -g <pkg>` — the only form
134
+ // that installs a .NET global tool. `-g` matches the remediation the C#
135
+ // descriptor provider prints (csharpDescriptorProvider.ts:219), so
136
+ // `prepare-repo` installs exactly what the fix text tells the user to
137
+ // install. `packageManagerCommand` returns null for csharp, so this branch
138
+ // is the ONLY way a csharp install action is produced — a package id can
139
+ // never be appended to `dotnet restore`.
140
+ for (const pkg of packages) {
141
+ actions.push({
142
+ kind: 'install-lockfile',
143
+ command: ['dotnet', 'tool', 'install', '-g', pkg],
144
+ packages: [pkg],
145
+ description: `Install .NET global tool ${pkg} via dotnet tool install -g`,
146
+ });
147
+ }
148
+ }
149
+ else {
150
+ const pmCmd = packageManagerCommand(lockfile, lang);
151
+ if (pmCmd) {
152
+ actions.push({
153
+ kind: 'install-lockfile',
154
+ command: [...pmCmd, ...packages],
155
+ packages,
156
+ description: `Install ${packages.join(', ')} via ${pmCmd[0]}`,
157
+ });
158
+ }
128
159
  }
129
160
  }
130
161
  // verify-tool: probe tool availability
@@ -244,7 +275,7 @@ const INSTALL_ALLOWLIST = new Set([
244
275
  'create-venv',
245
276
  ]);
246
277
  /** Binaries each allowlisted install kind may spawn, compared by basename. Covers every in-repo
247
- * command producer: packageManagerCommand -> pnpm|yarn|npm|pip, create-venv -> python3,
278
+ * command producer: packageManagerCommand -> pnpm|yarn|npm|pip|dotnet, create-venv -> python3,
248
279
  * install-lockfile spreads that command after its own flags, resolvePipCommand -> venv `python` | python3.
249
280
  *
250
281
  * LIMIT: gates the EXECUTABLE NAME only — never the arguments, never the script that executable
@@ -253,7 +284,7 @@ const INSTALL_ALLOWLIST = new Set([
253
284
  * confinement: a passing allowlist is not proof that the spawned process is sandboxed.
254
285
  */
255
286
  const INSTALL_BINARY_ALLOWLIST = new Map([
256
- ['install-lockfile', new Set(['npm', 'pnpm', 'yarn', 'pip', 'python', 'python3'])],
287
+ ['install-lockfile', new Set(['npm', 'pnpm', 'yarn', 'pip', 'python', 'python3', 'dotnet'])],
257
288
  ['create-venv', new Set(['python', 'python3'])],
258
289
  ]);
259
290
  const INSTALL_TIMEOUT_MS = 60_000;
@@ -464,6 +495,7 @@ function resolvePython(cwd) {
464
495
  * (a) Node import probe: `@barney-media/crap-typescript-core` resolvable
465
496
  * (b) CLI version probe: `npx --no-install crap-typescript --version` exit 0
466
497
  * (c) Python stdlib probe: venv-aware `python -c "import ast"`
498
+ * (d) .NET SDK probe: `dotnet --version` exit 0
467
499
  * Returns re-detected stack, per-probe status, and aggregate `ok`.
468
500
  */
469
501
  export async function verifyInstall(stack, options) {
@@ -510,6 +542,23 @@ export async function verifyInstall(stack, options) {
510
542
  : `${pyBin} not found; create .venv via "python3 -m venv .venv" and re-run`;
511
543
  analyzers.push({ name: 'python-stdlib-ast', status: 'unfixable', detail: guidance });
512
544
  }
545
+ // (d) .NET SDK probe — `dotnet --version` exit 0. LANGUAGE-UNGUARDED, matching
546
+ // (a)/(b)/(c): all four run for every repo. Plan Task 7 item 8 forbids a language gate
547
+ // here — it would diverge from the sibling probes. Consequence, recorded in the task
548
+ // report: `ok` now depends on the .NET SDK being on PATH, exactly as it already
549
+ // depends on python3 for probe (c).
550
+ try {
551
+ const { stdout } = await execFileAsync('dotnet', ['--version'], { cwd, timeout: INSTALL_TIMEOUT_MS });
552
+ const line = stdout.split('\n')[0]?.trim() ?? '';
553
+ analyzers.push({ name: 'dotnet-sdk', status: 'ok', detail: `exit 0: ${line}` });
554
+ }
555
+ catch {
556
+ analyzers.push({
557
+ name: 'dotnet-sdk',
558
+ status: 'unfixable',
559
+ detail: 'dotnet not found on PATH; install the .NET SDK from https://dotnet.microsoft.com/download and re-run prepare-repo',
560
+ });
561
+ }
513
562
  return {
514
563
  reDetected,
515
564
  analyzers,
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.4.2";
4
+ readonly version: "0.4.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.4.2' };
2
+ export const rulesProvenance = { tool: 'checkchange', version: '0.4.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.4.2",
3
+ "version": "0.4.4",
4
4
  "license": "MIT",
5
5
  "packageManager": "pnpm@11.17.0",
6
6
  "type": "module",