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

# Merge-Nested-Ifs

#### Sourcery rule id: `merge-nested-ifs`

#### Description

Merge nested if conditions


#### Before

```javascript
if (a && b) {
    if (c) {
      something();
      d = other_thing;
    }
}
```

#### After

```javascript
if (a && b && c) {
    something();
    d = other_thing;
}
```



#### Explanation

Reading deeply nested conditional code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two `if` conditions can be combined using
`and` is an easy win.
