Remove the 14 duplicate blocks the 12-line check finds, then tighten the check
Back to our planIn plain words: the new duplicate-code check (#621) only flags a repeated block that is at least 12 lines and 80 tokens long, and that setting misses real copies. With the token floor lowered to 30 (so the rule is just "12 lines"), jscpd finds 14 existing clones. Rule 1 of the guard rails (build once, reuse everywhere) says each one becomes a shared thing; this task does that, then lowers minTokens in .jscpd.json to 30 so the check follows the 12-line rule.
The 14 clones (file ranges, lines, tokens), as found on main at {'eb8e2a2'} plus #621:
- intelligence/runner/lib/pipeline.mjs [79:21 - 94:4] (15 lines, 61 tokens) ↔ intelligence/runner/lib/process.mjs [13:23 - 27:5]
- src/app/(payload)/admin/[[...segments]]/not-found.tsx [6:22 - 21:15] (15 lines, 132 tokens) ↔ src/app/(payload)/admin/[[...segments]]/page.tsx [6:18 - 21:11]
- src/app/(frontend)/events/[slug]/page.tsx [69:45 - 95:12] (26 lines, 168 tokens) ↔ src/app/(frontend)/posts/[slug]/page.tsx [75:43 - 103:12]
- src/modules/site/cms/callToActionBlock.ts [16:5 - 32:18] (16 lines, 116 tokens) ↔ src/modules/site/cms/hero.ts [41:5 - 57:16]
- src/modules/site/cms/archiveBlock.ts [15:27 - 27:29] (12 lines, 96 tokens) ↔ src/modules/site/cms/hero.ts [42:23 - 54:19]
- src/modules/news/cms/posts.ts [57:28 - 73:14] (16 lines, 82 tokens) ↔ src/modules/site/cms/pages.ts [43:28 - 58:24]
- src/modules/news/cms/posts.ts [193:32 - 205:2] (12 lines, 69 tokens) ↔ src/modules/site/cms/pages.ts [89:39 - 101:2]
- src/modules/events/cms/events.ts [1:1 - 14:32] (13 lines, 76 tokens) ↔ src/modules/news/cms/posts.ts [1:1 - 14:26]
- src/modules/events/cms/events.ts [56:29 - 71:16] (15 lines, 76 tokens) ↔ src/modules/site/cms/pages.ts [43:28 - 58:17]
- src/modules/directory/cms/faq.ts [34:30 - 46:26] (12 lines, 65 tokens) ↔ src/modules/directory/cms/teamMembers.ts [81:8 - 93:20]
- src/modules/contact/cms/formBlock.ts [30:8 - 43:4] (13 lines, 97 tokens) ↔ src/modules/site/cms/hero.ts [43:23 - 29:6]
- src/modules/accounts/ui/SignUpForm.client.tsx [102:71 - 119:53] (17 lines, 133 tokens) ↔ src/modules/accounts/ui/VerifyAccount.client.tsx [115:35 - 136:55]
- src/modules/accounts/ui/ChangePasswordForm.client.tsx [53:81 - 67:68] (14 lines, 108 tokens) ↔ src/modules/accounts/ui/SignUpForm.client.tsx [102:62 - 119:70]
- src/app/(frontend)/confirm-email/page.tsx [12:63 - 24:4] (12 lines, 55 tokens) ↔ src/app/(frontend)/verify-account/page.tsx [11:70 - 23:4]
Notes: some are Payload config (fields that repeat across blocks and collections), some are the same page markup (events and posts detail pages), and some are form markup in accounts/ui. Each needs a look: a shared field config in platform/payload or the owning module's cms/, a shared component or helper, or, for pure import lists, a deliberate exception noted in .jscpd.json.
Acceptance criteria
- Not done:
npx jscpdwithminTokens: 30reports 0 clones (or each remaining one is an explained exception in.jscpd.json) - Not done:
minTokensin.jscpd.jsonis 30 anddocs/project.mdand the guard-rails table say "12+ lines" - Not done: Each shared piece has a test, and pages and admin screens that use it look and work the same (checked on a phone)
- Not done: Split into several PRs by area if it is bigger than size L
Parent: epic #614 (clean up recently merged debt). Found by #611.
Generated by Claude Code, opens in a new tab