Skip to content

Refactor (packages/opencode/src/provider/provider.ts:932): Duplicate (20 lines) with snowflake-cortex.ts - #112

Draft
vixter001 wants to merge 1 commit into
CMU-313:mainfrom
vixter001:main
Draft

Refactor (packages/opencode/src/provider/provider.ts:932): Duplicate (20 lines) with snowflake-cortex.ts#112
vixter001 wants to merge 1 commit into
CMU-313:mainfrom
vixter001:main

Conversation

@vixter001

@vixter001 vixter001 commented Sep 7, 2026

Copy link
Copy Markdown

P1B: Starter Task: Refactoring PR

1. Issue

#95

packages/opencode/src/provider/provider.ts

provider.ts is opencode's provider service — it resolves/loads LLM providers and models for use by the AI SDK.

Scope of your refactoring within that file
I edited the custom() function by deleting and restructuring duplicated lines. (specifically at line 932)

Qlty‑reported issue
Duplicate (20 lines) with snowflake-cortex.ts

2. Refactoring

Duplicated code across the database makes things harder to debug if there is a bug, and makes style unnecessarily convoluted. It can also introduce inconsistencies and confusion throughout the database.

I made changes by deleting most of the duplicated code and refactoring the code to return the response earlier. This way, there is no duplicated code and things are much more clear.

3. Validation

Bun lint and bun test passes:
image

image

I created a test that ensures that the provider.ts file passes SSE through unchanged for non-OAuth tokens. This would make sure the deletion did not change the purpose of the function and file and ensure that everything runs smoothly.

Here is the code for the tests.
image

Tests pass during Cl
Screenshot 2026-09-07 141633

qlty smells --no-snippets <full/path/to/file.ts> showing fewer reported issues after the changes.**
image

There is no longer an issue at line 932.

@vixter001
vixter001 marked this pull request as draft September 7, 2026 18:30
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