From c26c3a53cac260e5d1f3392a594616c2208e4cf6 Mon Sep 17 00:00:00 2001 From: RobertLD Date: Sat, 21 Mar 2026 20:26:22 -0400 Subject: [PATCH] fix(quality): reduce cognitive complexity of spiderUrl generator (S3776) Flatten the nested `if (depth > 0) { if (skipped) continue; }` block into a single guarded continue, and remove the redundant inner maxPages check (already guarded by the while condition and the post-loop abortReason assignment). Brings cognitive complexity from 19 down to 14, resolving SonarCloud CRITICAL S3776. Co-Authored-By: Claude Sonnet 4.6 --- src/core/spider.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/core/spider.ts b/src/core/spider.ts index d581d3b..7c44a57 100644 --- a/src/core/spider.ts +++ b/src/core/spider.ts @@ -491,15 +491,7 @@ export async function* spiderUrl( if (visited.has(url)) continue; visited.add(url); - if (depth > 0) { - const skipped = await shouldSkipNonSeedUrl(url, config, robotsCache, stats, log); - if (skipped) continue; - } - - if (stats.pagesFetched >= config.maxPages) { - stats.abortReason = "maxPages"; - break; - } + if (depth > 0 && (await shouldSkipNonSeedUrl(url, config, robotsCache, stats, log))) continue; const raw = await fetchSpiderPage(url, config, stats, log); if (!raw) continue;