Skip to content

Feature - #102

Open
jku0227 wants to merge 3 commits into
CMU-313:mainfrom
jku0227:feature
Open

Feature#102
jku0227 wants to merge 3 commits into
CMU-313:mainfrom
jku0227:feature

Conversation

@jku0227

@jku0227 jku0227 commented Sep 7, 2026

Copy link
Copy Markdown

P1B: Starter Task: Refactoring PR

1. Issue

Link to the associated GitHub issue:
#86

Full path to the refactored file:
packages/core/src/plugin/provider/amazon-bedrock.ts

What do you think this file does?
(Your answer does not have to be 100% correct; give a reasonable, evidence‑based guess.)
Registers the Amazon Bedrock provider plugin

What is the scope of your refactoring within that file?
(Name specific functions/blocks/regions touched.)
Only resolveModelID and the constants above it.

Which Qlty‑reported issue did you address?
(Name the rule/metric and include the BEFORE value; e.g., “Cognitive Complexity 18 in render()”.)
Function with many returns (count = 7): resolveModelID

2. Refactoring

How did the specific issue you chose impact the codebase’s maintainability?
There were seven returns inside nested ifs + inline model/region lists which made the code hard to follow and easy to break when adding a new region.

What changes did you make to resolve the issue?
Split the region-specific branching out of resolveModelID into three small resolvers, usPrefix, euPrefix, and apPrefix, each returning a prefix or undefined, and selected between them with a PREFIX_RESOLVERS lookup. Also replaced the four repeated list.some((item) => value.includes(item)) calls with a single matchesAny helper.

How do your changes improve maintainability? Did you consider alternatives?
Each region's rule is now a 2-3 line function, and adding a region is one resolver + one table entry rather than another nested block and return. I considered a switch on the region prefix but it still left four returns with all the logic in one function.

3. Validation

How did you validate that the change is correct?
Screenshot 2026-09-07 at 10 40 47 AM
Screenshot 2026-09-07 at 11 12 26 AM

Attach a screenshot of the test coverage showing the lines were executed by the tests.
image

Attach a screenshot showing the tests that cover the change passing during CI
Screenshot 2026-09-07 at 11 28 03 AM

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

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