Skip to content

ALL-FUNC0001 · function_statement_count

Limit direct statements in one callable body.

This is a deterministic rule for all languages. Read its implementation.

Count statements directly owned by each function, method, or nested function after removing its docstring. Statements inside an owned branch remain part of the branch statement rather than being counted twice. Declarative query bodies are excluded because they describe one relational plan rather than a sequence of host operations.

The finding names the callable, its exact source span, and its direct statement count. The value is that statement count. A project may override the rule-owned ceiling of ten.

A generated, vendored, or framework-constrained body is long for a reason nobody in this repository can change, so provider selection is where those are excluded. A cohesive numerical kernel or protocol adapter may need more than ten steps. Exclude that exact path only after checking that named sections would not make the algorithm easier to follow.

A function with eleven direct statements returns 11 and fails. A function with one if whose branches contain several statements returns 1 here while complexity rules measure the nested control flow.

  • Cites “Clean Code”, chapter 3, Functions
  • Cites Ruff PLR0915 too-many-statements. Open reference
  • Cites “A Philosophy of Software Design”, chapters 4 and 5