Search documentation of Metastatic

# Metastatic.Analysis.BusinessLogic.CallbackHell (Metastatic v0.13.2)

View Source

Detects deeply nested conditional statements (callback hell pattern).

This analyzer identifies code with excessive nesting of conditionals which creates "callback hell" - code that is hard to read, maintain, and reason about.

## Cross-Language Applicability

This pattern is universal and applies to all languages with conditionals:

- Python: Nested if/else chains
- JavaScript: Nested if/else or ternary operators
- Elixir: Nested case statements
- Rust: Nested match expressions
- Go: Nested if/else statements

## Examples

### Bad (Elixir)

    case get_user(id) do
      {:ok, user} ->
        case get_account(user) do
          {:ok, account} ->
            case process(account) do
              {:ok, result} -> result
            end
        end
    end

### Good (Elixir)

    with {:ok, user} <- get_user(id),
         {:ok, account} <- get_account(user),
         {:ok, result} <- process(account) do
      result
    end

### Bad (Python)

    if user is not None:
        if user.active:
            if user.has_permission():
                return True

### Good (Python)

    return (user is not None and
            user.active and
            user.has_permission())

## Configuration

- `:max_nesting` - Maximum allowed nesting depth (default: 2)