Unmemoized recursive function calls itself twice
Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.
What it detects
A function calls itself two or more times within a single line of its own body (the classic return fib(n-1) + fib(n-2) shape), with no @lru_cache/@cache decorator and no "memo"/"cache" anywhere in the body. Without memoization this branches exponentially. Heuristic: a cache decorator or a "memo"/"cache" keyword anywhere in the function is treated as evidence it is already handled.
Why it matters
A function that calls itself two or more times within a single line of its own body (the classic return fib(n-1) + fib(n-2) shape) branches into two recursive calls at every level, so the total number of calls grows exponentially with the input size. Past a fairly small input this becomes seconds or minutes of pure recomputation of values that were already computed. This detector treats an @lru_cache/@cache decorator, or a "memo"/"cache" keyword anywhere in the function body, as evidence memoization already exists, so a hit here usually means it genuinely does not.
How to fix it
The simplest fix is to add @functools.lru_cache (or @functools.cache on Python 3.9+) above the function definition, which memoizes results per argument tuple with no other code changes. Alternatively, thread through an explicit memo dict/argument, or rewrite the function iteratively (bottom-up) to avoid the recursive call-stack cost as well.
The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing
Does your repo trip this check?
Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.
Scan your repo