Skip to content

refactor(core): remove dead output-parser facade + dead branches (#156) - #195

Open
Galmanus wants to merge 1 commit into
Dione-b:mainfrom
Galmanus:chore/156-dead-code
Open

refactor(core): remove dead output-parser facade + dead branches (#156)#195
Galmanus wants to merge 1 commit into
Dione-b:mainfrom
Galmanus:chore/156-dead-code

Conversation

@Galmanus

Copy link
Copy Markdown
Contributor

Summary

Closes #156. Each of the four items was verified against the source before touching it.

1. Unused output-parser façade — deleted

stellar-cli/stellar-cli-output-parser.ts was imported only by its own test; every production caller imports parse-contract-id / parse-wasm-hash / version directly, and it is not re-exported from index.ts. Deleted it (the issue's second option).

Coverage note: the façade test was the only test exercising parseStellarCliVersion (there was no version.test.ts). Those two cases are preserved in a new stellar-cli/version.test.ts importing the parser directly, so no coverage is lost.

2. Below-min probe underreported — fixed

probeMissingStellarCliFeatures, when version < STELLAR_CLI_MIN_VERSION, returned only ["contract-invoke-sign"], silently omitting contract-build and contract-deploy. Now returns all of STELLAR_CLI_REQUIRED_FEATURES. Added a unit test (the below-min branch returns early, so it needs no live CLI).

3. ensureRootBindingIndex dead branch — collapsed

Both the "matches" and "differs" cases returned without writing; only the catch (file absent) wrote. Collapsed to try { readFile; return } catch { writeFile }, keeping a comment documenting that any existing index is preserved. Behavior unchanged — the 16 existing binding-patch tests still pass.

4. version.ts __filename guard — removed

Verified safe: the CJS build (dist/index.cjs) rewrites import.meta.url via a tsup banner shim (pathToFileURL(__filename).href), so createRequire(import.meta.url) resolves in the ESM source, the ESM dist, and the CJS dist. The declare const __filename ternary was genuinely redundant.

Verification

tsc --noEmit clean; full core suite 496/496 pass (86 files).

- Delete the stellar-cli-output-parser façade: no production caller
  imported it (all use parse-contract-id/parse-wasm-hash/version
  directly) and it was not re-exported from index. Its only coverage of
  parseStellarCliVersion is preserved in a new version.test.ts.
- probeMissingStellarCliFeatures: below the minimum version, report every
  required feature (contract-build/deploy/invoke-sign), not just
  contract-invoke-sign.
- ensureRootBindingIndex: collapse the two return-without-write branches
  (matches / differs) into a single 'existing index is preserved' path;
  behavior is unchanged, the redundant equality check is gone.
- version.ts: drop the __filename fallback. The CJS build shims
  import.meta.url via a tsup banner, so createRequire(import.meta.url)
  resolves in ESM source, ESM dist, and CJS dist alike.

Closes Dione-b#156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: dead code — unused output-parser facade, below-min probe, dead branches in ensureRootBindingIndex and version.ts

2 participants