max-statements

Path
lint/complexity/max-statements
Default
Off, opt in
Origin
Falcon
Rule
264 of 512

Reports function bodies with too many statements.

max-statements (integer, default: 20) limits executable and declaration statements, excluding blocks, labels, empty statements, and local function declarations. Nested callable bodies are measured independently.

Invalid

example.dartdart
void handle() {
  print(1);
  if (true) { print(2); }
}
Function contains 3 statements (max 2). Extract smaller functions.
1void handle() {

Valid

example.dartdart
void handle() { print(1); print(2); }
void outer() {
  void local() { print(1); print(2); }
  local();
}
int arrow() => 1;

Configure max-statements

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "complexity": {
        "max-statements": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/complexity/max-statements: <reason>