Skip to main content

avoid-recursive-calls

Warns when a function calls itself recursively.

Dart does not support tail call optimization, so when working with a recursion there is always a chance to hit a StackOverflow error. Consider rewriting recursion to a stack instead.

Example

❌ Bad:

String some() {
// LINT: Avoid calling the same function recursively.
// Try rewriting the code without recursion.
return some();
}

✅ Good:

String some() {
return another();
}