Skip to content

fix(js): count catch clauses, not throws, as exception decision points - #201

Merged
DaisukeYoda merged 1 commit into
mainfrom
fix/js-throw-complexity
Oct 10, 2026
Merged

DaisukeYoda merged 1 commit into
mainfrom
fix/js-throw-complexity

Conversation

@DaisukeYoda

Copy link
Copy Markdown
Member

Closes #171.

Every JavaScript throw added one to complexity and was reported in exception_handlers. #200 removed the core rule that caused this, and this PR bumps core to v0.2.8. The JavaScript analyzer now counts catch clauses from the AST. Each catch clause adds one to complexity and to exception_handlers, and a throw adds nothing. This matches how C++ and pyscn count exception handlers.

For the issue's repro, threeThrows goes from 6 to 3 and tryCatch goes from 3 to 2 with one handler. On imbue-ai/latchkey@d2ee791, prepareCurlInvocation goes from 22 to 16, and the medium-risk count goes from 36 to 22.

#171)

Bump core to v0.2.8, which no longer counts exception edges as decision
points. Each catch clause now adds one to complexity and to
exception_handlers, and a throw adds nothing, matching C++ and pyscn.
@DaisukeYoda
DaisukeYoda merged commit 19b3730 into main Oct 10, 2026
4 checks passed
@DaisukeYoda
DaisukeYoda deleted the fix/js-throw-complexity branch October 10, 2026 14:05
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.

[BUG][auto] ts/throw-statement-counted-as-decision-point: every throw adds one to complexity and is counted as an exception handler

1 participant