> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# high-branch-complexity

> A function reaches a branch complexity score of 15.

## What it flags

A JS/TS function reaches a score of 15.

## How to review or fix

Start at one and count each conditional, loop, switch, catch or ternary. A flat switch contributes one decision. When most of a function's decisions are plain bail-outs (an `if` with no `else` that only returns, throws, continues or breaks, at the top of the body), up to twelve of them count half toward the 15 and any further ones count in full, so a function made only of such guards is reported from twenty guards on. The reported score is still the plain count.

## Inline fix

Combines nested conditional expressions with the same literal success label while preserving short-circuit order. Other fixes merge nested `if`s, join adjacent same-exit `if`s with `||`, turn `x ? true : false` into `Boolean(x)`, and `if (!x) x = value` into `x ||= value`.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "high-branch-complexity": "off" }
}
```

For JavaScript and TypeScript files, an object with a `level` and `options` sets the rule's threshold. It takes a `maxComplexity` option, a positive integer. The rule then reports a function whose weighted score is above `maxComplexity`. Without the option, it reports from a weighted score of 15.

```json theme={null}
{
  "rules": {
    "high-branch-complexity": { "level": "warn", "options": { "maxComplexity": 20 } }
  }
}
```

`level` is required: `"warn"` reports findings without changing the exit code. An `overrides` entry can set different options for the files it matches, and its options win over the top-level ones.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.