Repository navigation
test: share repeated boundary preambles to restore the jscpd gate - #2691
Conversation
Main fails its own duplicate-code gate: npm run jscpd reports 3.01% duplicated lines against the 3.0% ceiling in .jscpd.json, so Static checks exits 1 for every branch that merges on top of it. Collapse blocks these files already repeat locally. The count lands at 2.96% (15807 -> 15564 duplicated lines, 1480 -> 1460 clones) with no production code touched and no assertion changed. - reconstructionCoverage: one fixture helper narrows the workspace, its first verifier result and boundary; the two newest-observation cases share one evaluation helper. - NativeUiObservation: one PNG payload builder and one screenshot observation call replace five literal copies. - installScript: the fixture installer environment is built once and spread by the exec, pipe and PTY runs. - setupClientConfigCleanupOwnership: the VS Code setup preamble and the close-reclaims-handle tail are each stated once. - captureCleanup: the two pre-service refusals share one CLI harness.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Appreciate the careful cleanup, @NIU-123370. Sharing repeated fixture setup across the focused tests brought the duplicate-code measure back under the repository’s gate without changing the test cases or their assertions. |
Main fails its own duplicate-code gate
npm run jscpdis the step that exits 1 inside Static checks, and it does so oncurrent main, not because of any one branch.
.jscpd.jsonsets"threshold": 3.0.Measured on this box against three trees:
npm run jscpdbb540826— base a recently green PR branch usedbf34d0d2— current mainThe main run for
4276aaf1already concludedfailureat 06:58Z today on the samestep, which is why open PRs such as #2486 show a
Static checksred while their owndiff contributes nothing to it.
What this changes
Five test files repeat blocks inside themselves, and one shared fixture gains the
narrowing those repeats each re-state. No production code, no assertion, and no test
case is added or removed: the same set of files reports 79 passed before and after
this change on this box.
reconstructionCoverage— one fixture helper returns the complete workspace withits first verifier result and boundary narrowed, replacing six copies of the same
preamble; the two "newest observation fails" cases share one evaluation helper.
NativeUiObservation— one PNG payload builder and one screenshot observation callreplace five literal copies. The builder reads
width/heightfrom the buffer, soeach payload keeps exactly the values the copies hardcoded for these fixtures.
installScript— the fixture installer environment is built once and spread by theexec, pipe and PTY runs, keeping each one's
...process.envand...overridesposition.
setupClientConfigCleanupOwnership— the VS Code setup preamble and therelease-then-close assertion tail are each stated once.
captureCleanup— the two "refuse before the service is reached" cases share oneCLI harness; each still asserts its own stdout substring.
Net effect: 15807 → 15564 duplicated lines, 1480 → 1460 clones, 3.0097% → 2.9641%.
Deliberately not touched: the largest new duplication is
src/captures/TsharkCaptureProvider.tsagainstsrc/signals/SigrokRecordingProvider.ts(15 clones, 304 lines, from #2487 and #2496). That is a cross-domain design decision for
those authors rather than a mechanical collapse, so this PR leaves it alone.
Verification
npm run jscpdnpx tsc --noEmitnpx oxlintnpx oxfmt --check .npx knipnpm run verify:architecture-guardsnpm run verify:test-discoverynpm run scan:todosbf34d0d2tests/boundary/mcp/reconstructionCoverageMcp.test.ts(other consumer of the changed fixture)Node 26.11.1 on macOS. No file here is touched by any of the 203 currently open PRs.
Note on the threshold
This buys back headroom (≈190 duplicated lines before the gate trips again), it does
not make the gate self-maintaining. If the project would rather have a ratchet — a
committed ceiling that only ever goes down, checked in
check:ci— say so and I canlook at that separately.