Skip to content

refactor: delete three unreferenced functions - #50

Merged
beeman merged 1 commit into
mainfrom
beeman/remove-dead-exports
Sep 4, 2026
Merged

refactor: delete three unreferenced functions#50
beeman merged 1 commit into
mainfrom
beeman/remove-dead-exports

Conversation

@beeman

@beeman beeman commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Last item from the cleanup audit that followed the command-factory series. It is much smaller than expected, and that is the main finding.

What the audit claim was, and what is actually true

A grep-based scan suggested "~72 exports with no consumer" and I called it a mechanical pass. Running knip over the whole project — entry points src/cli.ts, src/templates.ts, scripts/*.ts and every test suite — and then classifying each hit by whether the symbol is referenced inside its own file:

count
Referenced inside their own file — DI interfaces, default* injection helpers, module constants 65
Unreferenced anywhere — genuinely dead 3

So this PR deletes three functions. It is not a sweep.

The three

  • sdkComponentName (check-android-sdk.ts) — one-line wrapper around basename
  • executableDirectory (doctor-environment.ts) — one-line extname ternary
  • planOwnedForwards (apply-forwards.ts) — 18 lines that pre-computed the ownership a detached localnet session was about to claim

The third was worth checking rather than trusting the tool on, because its doc comment described real behaviour and dead code sometimes means an unfinished feature. It is obsolete, not missing: the detach path records ownership from the forwards that actually landed — writeOwned(mergeOwnedForwards(...)) over owned.values() in localnet-feature-start.ts — rather than from a pre-applied plan, and the comment there explains why that ordering is the safe one. planOwnedForwards' own comment described the approach that replaced it.

Three imports narrowed as a result: basename, dirname/extname/resolve, and ownedForwards.

The 65 are left alone deliberately

Every one is referenced inside its own file. They are dependency-injection interfaces (RunLocalnetStartDependencies, EnsureKeystoreDependencies, ReadWebshellManifestDependencies and friends), the default* helpers they carry, and module constants. Dropping export from them would touch some 25 files, delete the documented injectable surface this repo exports consistently, and change nothing that runs.

AppOptions is in that set and stays exported: it is the argument contract for createApp and runApp.

knip is not added as a dependency

With 65 of 68 findings intentional, a CI gate would need 65 ignores to stay green and would report nothing useful. It is more valuable run by hand when the question comes up again. Wiring it in permanently with a deliberate ignore list is a reasonable separate change if you want the standing check.

Verification

bun run ci — build, lint, tsc -b --noEmit, 487 pass / 0 fail. A knip re-run confirms 68 → 65 with exactly these three gone.

Noted, not addressed

Two duplications surfaced along the way, both behavioural questions rather than moves:

  • doctor/data-access/check-android-devices.ts has its own parseAdbDevices and AdbDevice, unrelated to the ones in device/data-access and carrying a kind field
  • doctor/data-access/doctor-environment.ts has its own runExecutable, distinct from core/data-access/run-executable.ts and with a different signature — (command, args) returning { path, stdout, stderr } versus (cmd[]) returning a string

Doctor has quietly grown a parallel command layer. Consolidating it would change what doctor reports, so it does not belong in a dead-code PR.

Summary by CodeRabbit

  • Refactor
    • Removed unused internal utilities and supporting imports.
    • Simplified environment and local network forwarding code by eliminating obsolete functionality.

`knip` over the whole project — with `src/cli.ts`, `src/templates.ts`, `scripts` and the test suites as entry points — reports 68 exports with no consumer outside their own file. Only three of them are unreferenced anywhere:

- `sdkComponentName` in `check-android-sdk.ts`, a one-line wrapper around `basename`
- `executableDirectory` in `doctor-environment.ts`, a one-line `extname` ternary
- `planOwnedForwards` in `apply-forwards.ts`, which pre-computed the ownership a detached localnet session was about to claim

The third is the only substantive one, and it is obsolete rather than unfinished: the detach path records ownership from the forwards that actually landed (`localnet-feature-start.ts`, `writeOwned(mergeOwnedForwards(...))` over `owned.values()`) instead of from a pre-applied plan, and the comment there explains why that ordering is the safe one. Its own doc comment described the superseded approach.

The other 65 findings are left alone deliberately. Every one is referenced inside its own file — they are dependency-injection interfaces (`RunLocalnetStartDependencies`, `EnsureKeystoreDependencies` and friends), the `default*` injection helpers they carry, and module constants. Dropping `export` from them would touch some 25 files, remove the documented injectable surface this repo exports consistently, and change nothing that runs. `AppOptions` is in that set too and stays exported: it is the argument contract for `createApp` and `runApp`.

knip is not added as a dependency. With 65 of 68 findings intentional, a gate would need 65 ignores to stay green and would report nothing useful; it is more valuable run by hand when the question comes up again.
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 01a3346

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

bun add https://pkg.pr.new/solana-mobile/solana-mobile-cli/solana-mobile@50

commit: 01a3346

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 902e5218-eeb0-495c-9656-1871e12fe944

📥 Commits

Reviewing files that changed from the base of the PR and between 4b8320d and 01a3346.

📒 Files selected for processing (3)
  • src/doctor/data-access/check-android-sdk.ts
  • src/doctor/data-access/doctor-environment.ts
  • src/localnet/data-access/apply-forwards.ts

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The changes remove unused imports and three exported helper functions from doctor and localnet data-access modules.

Changes

Unused helper and import cleanup

Layer / File(s) Summary
Remove unused helpers and imports
src/doctor/data-access/check-android-sdk.ts, src/doctor/data-access/doctor-environment.ts, src/localnet/data-access/apply-forwards.ts
Removed sdkComponentName, executableDirectory, and planOwnedForwards, along with their unused path and ownership imports.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 01a33

This cleanup removes obsolete helper APIs without changing active behavior. Current evidence indicates no merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removal of three unreferenced functions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch beeman/remove-dead-exports

Comment @coderabbitai help to get the list of available commands.

@beeman
beeman added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 4b28f7d Sep 4, 2026
7 checks passed
@beeman
beeman deleted the beeman/remove-dead-exports branch September 4, 2026 16:09
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.

1 participant