Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: calibrate knip + remove dead code (27 unused exports)#43

Merged
bvisible merged 4 commits into
mainfrom
chore/dead-code-cleanup
Jun 18, 2026
Merged

refactor: calibrate knip + remove dead code (27 unused exports)#43
bvisible merged 4 commits into
mainfrom
chore/dead-code-cleanup

Conversation

@bvisible

Copy link
Copy Markdown
Owner

What

Follow-up to the v3.6.3 release: add a calibrated knip config and remove the dead code it surfaced. No version bump / no publish in this PR — that happens at release time once reviewed.

Changes

1. Calibrated knip.json

  • Declares the real entry points (cli/**, tests/*, debug/*), scopes analysis to src/**, whitelists system binaries. Removes all structural false positives so knip reports only genuine dead code. Excluded from the npm tarball via .npmignore.

2. Dead-code removal — knip flagged 27 unused exports + 2 duplicate exports:

  • Removed 8 fully-unused functions: createBatchDeployScript, createHookScript, createProfile, mergeProfiles, createDefaultAliases, handleSSHKeyError, getToolConfigManager, closeServerSessions.
  • Dropped export from symbols used only within their own module (kept as private): saveCommandAliases, RESPONSE_FORMAT, saveHooksConfig, READONLY_DENY_REGEX, loadAliases, saveAliases, cleanupSessions, TUNNEL_STATES, ToolConfigManager, monitorTunnels, serverGroups.
  • Removed 4 unused export default (logger, server-groups, session-manager, tunnel-manager) and the unused {debug,info,warn,error} re-export → clears the duplicate-export warnings.

Net: −215 lines.

Why it's safe

  • All confirmed unused inside the repo (grep + knip with tests/cli/debug as entry points).
  • None are documented (README/docs/CHANGELOG) and the package has no exports field — its public surface is only the MCP server (src/index.js) + the CLI. No behavioral change.

Verification

  • npm test — full suite, incl. 46 sync-stats assertions
  • knipzero dead code remaining
  • ./scripts/validate.sh → all checks passed
  • ✅ all 22 src/ modules import cleanly (no broken imports from removed exports)
  • ✅ MCP server boots and answers tools/list
  • ℹ️ eslint: only the 5 pre-existing quotes errors (already on main; the CI step is continue-on-error)

Next steps (not in this PR)

  • Version bump + npm publish at release time.
  • Optionally add a knip step to .github/workflows/quality.yml to prevent dead code from creeping back in.

bvisible added 4 commits June 18, 2026 09:49
knip (calibrated in the previous commit) reported 27 unused exports + 2 duplicate exports, all confirmed unused inside the repo, none documented, and none part of the public surface (no "exports" field; the package exposes only the MCP server + CLI).

- Remove 8 fully-unused functions: createBatchDeployScript, createHookScript, createProfile, mergeProfiles, createDefaultAliases, handleSSHKeyError, getToolConfigManager, closeServerSessions.

- Drop the "export" keyword from 9 symbols used only within their own module (saveCommandAliases, RESPONSE_FORMAT, saveHooksConfig, READONLY_DENY_REGEX, loadAliases, saveAliases, cleanupSessions, TUNNEL_STATES, ToolConfigManager, monitorTunnels, serverGroups).

- Remove 4 unused "export default" (logger, server-groups, session-manager, tunnel-manager) and the unused {debug,info,warn,error} re-export, clearing the duplicate-export warnings.

Verified: knip now reports zero dead code; npm test + validate.sh green; all 22 src modules import cleanly; MCP server boots and answers tools/list.
…d code

Gets `eslint src/` to zero errors and zero warnings while keeping knip at zero.

- Auto-fixed 5 quote-style errors (eslint --fix).

- Removed unused imports in index.js and ssh-manager.js (health-monitor / database-manager / config / session / group / tunnel / backup helpers that were imported but never called there).

- Cascade on the now-orphaned exports: un-exported 16 symbols still used internally, deleted 5 dead functions + 3 dead consts (configLoader, DB_PORTS, getGroup wrapper).

- Fixed 11 unused local vars: dropped unused destructured bindings (database), skipped unused loop keys ([, x]), removed an unused callback param (reject) and an unused arg (hashedKey); kept side-effecting awaits by discarding their unused result (ssh, stream, sftp).

Verified: eslint clean, knip zero, npm test green, all 22 src modules import, MCP server boots and answers tools/list.
Adds a 'Run knip' step (knip@5, using the calibrated knip.json) to the quality job, right after ESLint. Unlike the eslint step it is NOT continue-on-error: it fails the build if dead code (unused exports/files/deps) is reintroduced. Safe to make blocking because this PR also brings knip to zero, so the workflow change and the clean tree land together.
@bvisible bvisible merged commit 9bce7fe into main Jun 18, 2026
5 checks passed
@bvisible bvisible deleted the chore/dead-code-cleanup branch June 18, 2026 11:29
bvisible added a commit that referenced this pull request Jun 18, 2026
Dead-code cleanup (PR #43) + knip dead-code CI gate. Declares knip as a devDependency so the binary is recognized and its version is stable across CI runs.
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