refactor: Extract numeric config parsing into a helper to eliminate 6 identical blocks#210
Open
frostyardyeti[bot] wants to merge 1 commit intomainfrom
Open
refactor: Extract numeric config parsing into a helper to eliminate 6 identical blocks#210frostyardyeti[bot] wants to merge 1 commit intomainfrom
frostyardyeti[bot] wants to merge 1 commit intomainfrom
Conversation
… 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>
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.
src/config.ts:155-204contains six near-identical blocks that each: (1)parseInt()an env var or config file value with a fallback default, (2) validate withNumber.isFinite()and an optional minimum, (3) fall back to the default on invalid input.The blocks for
maxClaudeWorkers,claudeTimeoutMs,maxCopilotWorkers,copilotTimeoutMs,maxCodexWorkers, andcodexTimeoutMsdiffer only in the env var name, config key, default value, and optional minimum (timeouts useMath.max(60_000, ...), workers use>= 0).Introduce a local helper like
parseIntConfig(envVar: string, fileVal: unknown, defaultVal: number, min?: number): numberand 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