Refactor (packages/opencode/src/provider/provider.ts:932): Duplicate (20 lines) with snowflake-cortex.ts - #112
Draft
vixter001 wants to merge 1 commit into
Draft
Refactor (packages/opencode/src/provider/provider.ts:932): Duplicate (20 lines) with snowflake-cortex.ts#112vixter001 wants to merge 1 commit into
vixter001 wants to merge 1 commit into
Conversation
vixter001
marked this pull request as draft
September 7, 2026 18:30
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.
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:

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.

Tests pass during Cl

qlty smells --no-snippets <full/path/to/file.ts>showing fewer reported issues after the changes.**There is no longer an issue at line 932.