refactor: remove dead code and add knip for dead export detection#282
Merged
Conversation
- Delete 3 unused test-hook functions that were never called: _resetPlatformCache (superseded by _resetAllCaches), _resetGitFilesCache, and _resetAdrParseCache - Unexport 25 interfaces that are only used within their own module: LoadedAdr, BlockedAdr, ParsedAdrEntry, AdrBriefing, DomainContext, ReviewContext, BriefAdrOptions, BuildReviewContextOptions, BuildSummaryOptions, RuleResult, SourcePos, DeviceCodeResponse, GitHubUserInfo, CreateAdrResult, UpdateAdrResult, InitOptions, PluginResult, InitResult, SignupResult, ClaudeSessionSummary, CursorSessionSummary, ReadCursorSessionOptions, CopilotSessionSummary, ReadCopilotSessionOptions, OpencodeSessionSummary, ReadOpencodeSessionOptions Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Deploying archgate-cli with
|
| Latest commit: |
35c157d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://70f9532e.archgate-cli.pages.dev |
| Branch Preview URL: | https://refactor-remove-dead-code.archgate-cli.pages.dev |
- Install knip and configure it to catch unused exports at CI time
- Wire `bun run knip` into the `validate` and `validate:coverage` pipelines
- Fix additional dead exports found by knip:
- Remove `getLogLevel` (log.ts), `opencodeStorageDir` (paths.ts),
`_setPublicProbeForTest` (repo-probe.ts, repo.ts),
`_setRepoContextSnapshot` (telemetry.ts)
- Unexport `DOMAIN_PREFIX_PATTERN` (project-config.ts)
- Tag upgrade.ts test hooks with `@internal` for dynamic import() usage
- Update CLAUDE.md and agent memory with knip in the validation pipeline
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
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.
Summary
_resetPlatformCache,_resetGitFilesCache,_resetAdrParseCache,getLogLevel,opencodeStorageDir,_setPublicProbeForTest,_setRepoContextSnapshot— all never calledbun run knipintovalidateso dead exports are caught at CI time going forwardimport()with/** @internal */so knip excludes themConfiguration
knip.jsonis configured to:tests/**/*.test.tsas entry points (catches test-only imports).archgate/adrs/*.rules.ts(dynamically loaded at runtime)@internal-tagged exports (test hooks using dynamicimport())ignoreExportsUsedInFileto avoid false positives on structurally-consumed typesTest plan
bun run validatepasses (729 tests, 0 lint errors, 0 ADR violations, knip clean)bun run knipreturns clean with no unused exports