asottile/dead

Recursive functions are not detected as dead

Closed this issue · 1 comments

Hi !
First : great work, I am in love with the pre-commit hook.

Here's a small issue I noticed : recursive functions are not flagged as dead as long as they at least call themselves.

How to reproduce :

Create the following function and never call it elsewhere. Then run pre-commit hook

def dead_function():
    print("dead")
    dead_function()

Expected result :

"dead_function is never called"

Actual result :

detect dead code.........................................................Passed

yep, there are callers so it will not detect it as dead