Rule proposal: `no-useless-recursion`
See original GitHub issueDisallow simple recursive function.
Fail
function foo(bar) {
if (bar.baz) {
return foo(bar.baz);
}
return bar;
}
Pass
function foo(bar) {
while (bar.baz) {
bar = bar.baz:
}
return bar;
}
function foo(bar) {
for (; bar.baz; bar = bar.baz) {}
return bar;
}
function foo(bar) {
if (Array.isArray(bar)) {
return bar.map(baz => foo(bar));
}
return bar;
}
I’m not sure how to define “simple”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Rule proposal: No implicit recursion · Issue #2664 - GitHub
This rule flags all recursive calls as invalid, except of those calls that are marked with an eslint-disable-line . This rule should help...
Read more >Common Patterns in Recursive Procedures - People @EECS
The only general principle we can offer is that you have to think about what base cases are appropriate, not just routinely copy...
Read more >Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >Binary Recursive Estimation on Noisy Hardware - Elsa Dupraz
Lk. This is why the theoretical analysis we propose studies the convergence of the expected gap E[|˜Lk − Lk|] between the noisy and...
Read more >Adaptive stepsizes for recursive estimation with applications in ...
techniques that uses this idea is the delta-bar-delta learning rule, proposed in Jacobs (1988), which decreases the stepsize exponentially ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Recursion is necessary for some algorithms, one can not simply forbid it generally. Maybe call it
no-useless-recursion
but detecting which cases are useless will probably be hard.I agree, it should be named
no-useless-recursion
and should only target some simple cases that can use loops instead.