Files
OmniRoute/open-sse
Diego Rodrigues de Sa e Souza de5e63a467 refactor(sse): decompose xAI Grok Imagine handler to fix complexity ratchets
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.
2026-07-15 11:42:06 -03:00
..
2026-05-26 23:51:47 -03:00
2026-07-13 09:12:40 -03:00
2026-07-07 13:14:06 -03:00
2026-07-13 09:12:40 -03:00
2026-07-13 09:12:40 -03:00
2026-06-12 23:49:22 -03:00
2026-06-29 08:40:06 -03:00