mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-17 12:42:21 +03:00
The file-size red was masking two ratchet regressions (the gate aborts on the first failure): complexity 2058 > 2056 and cognitive 891 > 890. Both came from the PR's own handleXaiVideoGeneration — a single 107-line function with complexity 37 / cognitive 24, tripping `complexity`, `max-lines-per-function` (2 complexity-ratchet violations) and `sonarjs/cognitive-complexity` (1 cognitive violation). Decompose it into four cohesive units instead of rebaselining: - resolveXaiVideoOptions() — timeouts/credential/endpoints/prompt - buildXaiVideoPayload() — OmniRoute body -> xAI create payload - createXaiVideoJob() — create-job POST -> request_id | error - pollXaiVideoJob() — poll loop -> terminal outcome - buildXaiVideoResponse() — outcome -> OpenAI-like response Both ratchets now sit exactly at baseline (complexity 2056, cognitive 890) and file-size stays under cap. pollXaiVideoJob reads Date.now() only in the loop condition, so the caller keeps its timeout budget semantics. No behavior change; the 7 existing tests pass unmodified.