Skip to content

Conversation

@panbanda
Copy link
Owner

Summary

  • Bug fix: Added catch_clause and except_clause to cognitive complexity flat types per SonarSource spec (catch should add +1 only, no nesting penalty)
  • Research citations: Added proper academic citations to 9 analyzers documenting their algorithmic basis

Changes

Bug Fix (complexity.rs, queries.rs)

Per SonarSource cognitive complexity specification, catch/except clauses should be "flat" constructs (add +1 but no nesting increment), similar to else clauses. This was missing from the implementation.

Research Citations Added

Analyzer Citations Added
complexity.rs McCabe (1976), SonarSource spec
hotspot.rs Tornhill (2015), threshold derivation formula
temporal.rs Ball et al. (1997)
ownership.rs Bird et al. (2011), Avelino et al. (2016)
graph.rs Page (1999), Brandes (2001), Martin (2003), Tarjan (1972)
cohesion.rs Chidamber & Kemerer (1994), Hitz & Montazeri (1995), Basili (1996)
duplicates.rs Broder (1997), Indyk & Motwani (1998)
churn.rs Nagappan & Ball (2005), documents 0.6/0.4 weights as heuristics
changes.rs Kamei et al. (2013), documents 6 missing JIT features as known limitation

Test plan

  • Added test for JavaScript catch_clause cognitive complexity
  • Added test for Python except_clause cognitive complexity
  • All 763 existing tests pass
  • cargo clippy clean
  • Coverage maintained at 75.28%

Generated with Claude Code

Per SonarSource spec, catch/except clauses should be flat constructs
(+1 only, no nesting penalty). Added catch_clause and except_clause
to flat node types.

Also adds research citations to 9 analyzers:
- complexity.rs: McCabe 1976, SonarSource spec
- hotspot.rs: Tornhill 2015, threshold derivation
- temporal.rs: Ball et al. 1997
- ownership.rs: Bird et al. 2011, Avelino et al. 2016
- graph.rs: Page 1999, Brandes 2001, Martin 2003, Tarjan 1972
- cohesion.rs: Chidamber & Kemerer 1994, Hitz & Montazeri 1995
- duplicates.rs: Broder 1997, Indyk & Motwani 1998
- churn.rs: Nagappan & Ball 2005 (documents 0.6/0.4 as heuristics)
- changes.rs: Kamei et al. 2013 (documents 6 missing features)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@panbanda panbanda merged commit 4907e9a into main Jan 24, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Jan 24, 2026
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.

2 participants