Skip to content

Refactor/storage adapter complexity - #117

Open
saabdullcmuq wants to merge 2 commits into
CMU-17313Q:mainfrom
saabdullcmuq:refactor/storage-adapter-complexity
Open

saabdullcmuq wants to merge 2 commits into
CMU-17313Q:mainfrom
saabdullcmuq:refactor/storage-adapter-complexity

Conversation

@saabdullcmuq

Copy link
Copy Markdown

Issue for this PR

Closes #97

Type of change

[ yes] Refactor / code improvement

What does this PR do?

Refactors storage.ts inside the enterprise package to take care of the smell issue of too much complexity with the adaptor selection and list filtering. The adapter is now a plain createAdapter(client, endpoint, bucket) factory exposed through Storage.forClient(...), which makes the module directly testable without real R2/S3 credentials or a configured OPENCODE_STORAGE_ADAPTER env var.

How did you verify your code works?

  • did a bun test test/core/storage.test.ts: 10 pass / 0 fail (read 200/404/500, write 200/500, remove 200/404, list parse, list before strict-<, list 500)

  • also did bun test --coverage test/core/storage.test.ts: storage.ts at 67.86% funcs / 66.09% lines (the uncovered lines are the lazy/env-var init path, intentionally left for integration)

  • checked bun run typecheck and it gave us clean

Screenshots / recordings

Qlty Smell Before:
image png

Qlty Smell After:
image png-2

Test Before:
image

Test After:
image

Checklist

  • [ yes] I have tested my changes locally
  • [yes ] I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@saabdullcmuq saabdullcmuq reopened this Sep 6, 2026
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.

P1B: Refactor packages/enterprise/src/core/storage.ts:12 Function with high complexity (count = 19): createAdapter

1 participant