Skip to content

Refactor (packages/codemode/src/stdlib/collections.ts): Function with many returns - #61

Open
Ahmed120515 wants to merge 1 commit into
CMU-17313Q:mainfrom
Ahmed120515:refactor-spread-items
Open

Refactor (packages/codemode/src/stdlib/collections.ts): Function with many returns#61
Ahmed120515 wants to merge 1 commit into
CMU-17313Q:mainfrom
Ahmed120515:refactor-spread-items

Conversation

@Ahmed120515

@Ahmed120515 Ahmed120515 commented Sep 4, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #59

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR reduces the number of returns in spreadItems by extracting the sandbox collection cases into spreadSandboxItems.

spreadItems still handles arrays and strings directly, and the helper handles SandboxMap, SandboxSet, and SandboxURLSearchParams. Unsupported values still do return undefined, so the behavior remains the same.

I also added a test for spreading URLSearchParams, since existing tests already covered Map and Set spreading.

How did you verify your code works?

  • qlty smells --no-snippets packages/codemode/src/stdlib/collections.ts reports no smells.
  • bun lint packages/codemode/src/stdlib/collections.ts packages/codemode/test/stdlib.test.ts passes with 0 warnings and 0 errors.
  • bun test test/stdlib.test.ts passes with 69 tests and 0 failures.
  • Coverage reports 100% function coverage and 98.04% line coverage for src/stdlib/collections.ts.
  • The full repository lint currently reports an unrelated existing TS2309 error in packages/web/src/types/lang-map.d.ts.

Screenshots / recordings

Before and after Qlty output, passing tests, coverage results, and targeted lint output are attached below.
Lab1B screenshot 1
Lab1B screenshot 2
Lab1B screenshot 3
Lab1B screenshot 4

Checklist

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

@Ahmed120515
Ahmed120515 force-pushed the refactor-spread-items branch from b3eecdc to 8e7b133 Compare September 4, 2026 14:29
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/codemode/src/stdlib/collections.ts:43): Function with many returns (count = 6)

1 participant