[NO-TICKET] Collapse duplicated helpers and drop dead code - #281
Merged
Merged
Conversation
Ten cleanups across the CLI, config, parsers and the protect scaffolder. None of them change behaviour: no printed string, doc or guide-checklist output is touched. The largest group is reuse. Four adapters in the protect scaffolder had each inlined a character-for-character copy of hasDependency() from the util module sitting next to them, and the CLI had four copies of the same resolveConfig() call, two of the same CI test, and two of the same gitignore-outcome line. The rest is dead code and naming: two exported functions with no callers anywhere, a pair of destructured locals whose underscore prefix said "unused" while both were read two lines later, and a bare 191 that now has the same name its twin already carries in site-name.ts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
/review |
|
Extracted shared helpers and removed redundant code without altering functionality. 🎯 Quality: 82% Excellent · 📦 Size: Medium 📈 This month: Your 155th PR — above team average · Averaging Excellent |
devlob
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Ten cleanups across the CLI, config, parsers and the protect scaffolder. Net 60 insertions / 114 deletions over ten files. Nothing here changes behaviour — no printed string, doc, or
guidechecklist output is touched.Why these were safe to collapse
Each one is either an exact reimplementation of something that already exists in the same directory, or code with no reachable caller. The four adapter
detectbodies were the clearest case:util.tsalready exportshasDependency(cwd, name), documented as "True whennameis in the project's dependencies or devDependencies", and four call sites had inlined it — sameJSON.parse, same spread, samecatch → false.For the two removals I checked reachability rather than assuming it: neither symbol is referenced anywhere in
src,tests,scriptsorfield-test, neither is re-exported fromindex.ts, and the package's exports map only exposes.and./protect— so no consumer could reach them either.Changes
Reuse
protect/install/adapters/{next,sveltekit,astro}.tsandprotect/install/generic.ts— four hand-rolled copies ofhasDependencyreplaced with the helper. The twodetectfunctions stay as functions because they're part of theAdaptershape; only the bodies collapsed. Astro and SvelteKit'sjoin/readimports were used only by the duplicated code, so they went too.cli.ts—initre-spelled the canonical-UUID regex inline; it now callsisCanonicalUuid, which was already in the module graph viaclient.ts.cli.ts— four identicalresolveConfig({ cwd, cliSiteUuid, cliEndpoint })blocks (and two near-identical ones) behindresolveCliConfig(args, extra?).mark-build's call is deliberately different — no--endpoint— so it stays inline.cli.ts— the same three-clauseprocess.env.CItest inclaimandlogin→runningInCi(), with theCI=falsecase explained once.cli.ts— the same.gitignore-outcome ternary in both →gitignoreOutcomeLine(). A third site nearby has different wording and indentation, so it was left alone.Dead code
normalize.ts— removedfindPackageInManifest. No caller, no test, not re-exported.map/coordinates.ts— removednamespaceOf. Same.login.ts— removedmakeTempDir, documented as "exported for tests" but referenced by none; its three imports went with it.Naming
config.ts— inpersistApiKey,_movedKey/_movedPulsecarried the "intentionally unused" underscore prefix but are read two lines later. Renamed to match what they do.site-url.ts— the bare191now has a name, mirroringNAME_MAX_LENGTHinsite-name.ts.Verified
npm test— 197 files, 3252 passed / 7 skipped, identical to the baseline taken before any edit.npm run typecheck,npm run build,npm run capabilities:checkandnpm run rule-contract:checkall clean.I also checked explicitly that no import was orphaned by a removal:
noUnusedLocalsis off, sotscwould not have caught one.No field-test run applies. The gates in
CLAUDE.mdcover the install prompt,AGENT-INSTALL.mdand theguidechecklist output — this PR changes none of them.Out of scope, worth a follow-up
baseFrom,BUILD_DIR_CANDIDATES,writeSecretFile,classifyDescriptor,MASKED_CHAR,routesBeforeamong them). All have real in-file callers, so only theexportkeyword is surplus. Eleven files of churn for no runtime effect, and some read as deliberate seams — left alone.packageTypeinregister.tsandpackageIsEsmingeneric.tsboth readpackage.json'stypebut return different shapes (string | undefinedvsboolean). Merging them means a new shared export and a judgement about which shape wins, which is more than a cleanup.Docs: not needed. Internal refactor, no flow, label or command output affected.
🤖 Generated with Claude Code