Skip to content

refactor: Extract numeric config parsing into a helper to eliminate 6 identical blocks#210

Open
frostyardyeti[bot] wants to merge 1 commit intomainfrom
yeti/improve-9fc3
Open

refactor: Extract numeric config parsing into a helper to eliminate 6 identical blocks#210
frostyardyeti[bot] wants to merge 1 commit intomainfrom
yeti/improve-9fc3

Conversation

@frostyardyeti
Copy link
Copy Markdown
Contributor

@frostyardyeti frostyardyeti bot commented Apr 1, 2026

src/config.ts:155-204 contains six near-identical blocks that each: (1) parseInt() an env var or config file value with a fallback default, (2) validate with Number.isFinite() and an optional minimum, (3) fall back to the default on invalid input.

The blocks for maxClaudeWorkers, claudeTimeoutMs, maxCopilotWorkers, copilotTimeoutMs, maxCodexWorkers, and codexTimeoutMs differ only in the env var name, config key, default value, and optional minimum (timeouts use Math.max(60_000, ...), workers use >= 0).

Introduce a local helper like parseIntConfig(envVar: string, fileVal: unknown, defaultVal: number, min?: number): number and replace the six blocks with six one-liners. This reduces ~50 lines to ~10 and ensures validation rules stay consistent across all backends (e.g., if you later want a minimum worker count, you change it in one place).


Automated improvement by yeti improvement-identifier

… parsing

Replace six near-identical parseInt/validate/fallback blocks for worker
count and timeout config values with a shared parseIntConfig() helper.
Reduces ~50 lines to ~10 while keeping validation consistent across all
AI backends (claude, copilot, codex).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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