Counts come from pattern matching on if, for, case, &&, ternary operators, and similar tokens. Minified bundles, JSX inside strings, or macros fool the counter. For CI gates on a whole repo, run ESLint complexity, SonarQube, or lizard instead. This page fits a quick paste during code review.
Pull request open. Reviewer asks whether the new handler is too branchy. You scroll three hundred lines, lose count of nested else if chains, approve anyway. Two weeks later a bug hides in branch fourteen.
Cyclomatic complexity turns branch piles into one integer. Higher number means more independent paths through the function. Test coverage tools care because each path wants an assertion.
What the counter adds up
Classic formula starts at one, then adds a point for each decision point McCabe counted in 1976.
if/else- Each branch arm counts. A lone
elsewithout a matchingifin the same function still registers. - Loops
for,while,doloops each add one. Nested loops stack fast on nesting depth too.switch/case- Switch header plus each case label. Default counts like any other case.
- Ternary & logic
?chains and&&/||in conditions. String literals with question marks do not count here unless the regex misreads them.try/catch- Exception paths add branches the same way guard clauses do.
- Nesting depth
- Separate metric. Tracks brace depth, not branch count. A flat series of ten
ifstatements scores high on cyclomatic complexity but low on nesting.
Three bands teams still cite in review
| Score | Typical label | What reviewers say | Weak spot |
|---|---|---|---|
| 1–10 | Low | Merge without debate. Few paths, easy unit tests. | Score ignores length. Ten one-liner guards still land in this band. |
| 11–20 | Moderate | Ask for a split or extract helper before merge. | Policy varies. Some teams cap at 15, others at 25. |
| 21+ | High | Refactor required. Risk of untested paths rises. | Legacy switch statements on enums hit 40 without feeling unreadable to the author. |
The quality badges on the workbench use these bands for maintainability, branch rating, and change risk. Swap the numbers in your linter config if your org document names different ceilings.
Per-function table vs whole-file score
The hero number sums every decision point in the pasted buffer. The breakdown table walks function declarations found by regex, then scores each body separately.
Arrow functions assigned mid-file, class methods without the function keyword, or Python decorators sometimes miss the detector. Paste suspicious blocks alone when the table shows zero functions but the file score looks high.
Where to go next on Toolexe
The Code Maintainability Index page blends Halstead volume, comment ratio, and cyclomatic complexity into a single 0–100 score. Use both when a function scores low on branches but still feels hard to read.
Duplicate logic inflates scores across files. Run the Code Duplication Detector on the same module before you extract helpers.
Branch count does not catch smell patterns. Pair numbers from here with the Code Smell Detector when naming, coupling, or god-class warnings matter more than raw if count.
Performance hotspots hide elsewhere. The Code Performance Analyzer looks at loop cost and synchronous work, not decision trees.
For debt spreadsheets and sprint planning, the Technical Debt Analyzer aggregates broader heuristics. Complexity rows from this tool feed those conversations.
Privacy: Analysis runs in your browser. Snippets never upload to Toolexe servers.
