Repository navigation
Commit 416179d
committed
refactor(u4): reuse main's errorCode helper and drop a one-line fsync wrapper
Two module-private helpers on this branch reimplemented `src/utils/errorCode.ts`,
which main already ships and which `safeWriteJson.ts` already imports:
- `safeWriteJson._scopeErrorCode` (2 call sites) -> `getErrorCode`
- `safeWriteText.errorCode` (8 call sites) -> `getErrorCode`
- `safeWriteText._fsyncFile(fd)` wrapped a single `fsSync.fsyncSync(fd)` call; the 4
call sites now call it directly.
Equivalence was checked at the call sites rather than assumed. All 10 uses compare
the result against a string code literal (`=== "ENOENT"`, `!== "ENOENT"`, and the
ENOTDIR variants), so the one real difference between the bodies - main's helper
additionally guards `typeof error.code === "string"`, `_scopeErrorCode` casts, and
`errorCode` stringifies - cannot change a decision: an absent or non-string code
yields `undefined` from `getErrorCode` and either a coerced string or `undefined`
from the private helpers, and both take the same branch against a string literal.
This is line-count work for the mutation gate, not a behaviour change: no assertion
moved, no expectation weakened, nothing dropped to make a number fit. The gate
counts changed executable lines per package against main and fails above 500. With
the repository's own counting rules applied locally (scripts/stryker-diff.mjs) at
b86511f the `extension` package measured 509, which is the number CI reported
for that head; after this commit the same selector reports 499 (safeWriteText
+272 -> +266, safeWriteJson +135 -> +131). The removals are the duplicate helper
bodies and the wrapper only.
Measured with pinned node v22.23.4 on this tree: prettier --check on both files
exit 0; eslint --max-warnings=0 on both files exit 0 with src/eslint-suppressions
json unmodified; tsc -p src/tsconfig.json --noEmit exit 0; misc shard 119 passed /
1 skipped files and 2118 passed / 17 skipped tests; core shard 197 files and 4280
passed / 9 skipped tests; misc shard restricted to the write-protocol proof files
(5 exist in this lane) 81 passed / 4 skipped; knip and knip --production, both with
--treat-config-hints-as-errors, exit 0; knip-policy test 8 pass / 0 fail.
The services shard is unchanged from the pre-commit baseline: the same 6 failures
with and without this commit, classed from the messages themselves - 5 `EPERM:
operation not permitted, symlink ...` fixture-creation failures in services/rules
(unprivileged symlink creation in %TEMP% on this box) and 1 `DaclRestoreError` in
safeWriteText.integration.spec.ts (the saved access rights could not be restored
here). The hosted windows leg passes both files at b86511f. Local results
describe this tree only: pnpm 10.8.1 ignores the `pnpm` field in package.json
(onlyBuiltDependencies, overrides), so a resolution difference is the first
candidate if a local shard disagrees with a hosted leg.1 parent b86511f commit 416179d
2 files changed
Lines changed: 16 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | 147 | | |
150 | 148 | | |
151 | 149 | | |
| |||
196 | 194 | | |
197 | 195 | | |
198 | 196 | | |
199 | | - | |
| 197 | + | |
200 | 198 | | |
201 | 199 | | |
202 | 200 | | |
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
206 | | - | |
| 204 | + | |
207 | 205 | | |
208 | 206 | | |
209 | 207 | | |
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | 211 | | |
225 | 212 | | |
226 | 213 | | |
| |||
245 | 232 | | |
246 | 233 | | |
247 | 234 | | |
248 | | - | |
| 235 | + | |
249 | 236 | | |
250 | 237 | | |
251 | 238 | | |
| |||
352 | 339 | | |
353 | 340 | | |
354 | 341 | | |
355 | | - | |
| 342 | + | |
356 | 343 | | |
357 | 344 | | |
358 | 345 | | |
| |||
426 | 413 | | |
427 | 414 | | |
428 | 415 | | |
429 | | - | |
| 416 | + | |
430 | 417 | | |
431 | 418 | | |
432 | 419 | | |
| |||
445 | 432 | | |
446 | 433 | | |
447 | 434 | | |
448 | | - | |
| 435 | + | |
449 | 436 | | |
450 | 437 | | |
451 | 438 | | |
| |||
460 | 447 | | |
461 | 448 | | |
462 | 449 | | |
463 | | - | |
| 450 | + | |
464 | 451 | | |
465 | 452 | | |
466 | 453 | | |
467 | 454 | | |
468 | 455 | | |
469 | 456 | | |
470 | 457 | | |
471 | | - | |
| 458 | + | |
472 | 459 | | |
473 | 460 | | |
474 | 461 | | |
| |||
505 | 492 | | |
506 | 493 | | |
507 | 494 | | |
508 | | - | |
| 495 | + | |
509 | 496 | | |
510 | 497 | | |
511 | 498 | | |
| |||
541 | 528 | | |
542 | 529 | | |
543 | 530 | | |
544 | | - | |
| 531 | + | |
545 | 532 | | |
546 | 533 | | |
547 | 534 | | |
| |||
554 | 541 | | |
555 | 542 | | |
556 | 543 | | |
557 | | - | |
| 544 | + | |
558 | 545 | | |
559 | 546 | | |
560 | 547 | | |
| |||
567 | 554 | | |
568 | 555 | | |
569 | 556 | | |
570 | | - | |
| 557 | + | |
571 | 558 | | |
572 | 559 | | |
573 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | 158 | | |
165 | 159 | | |
166 | 160 | | |
| |||
0 commit comments