Issue #2 wontfix

dead code calling other dead code

Anonymous avatarAnonymous created an issue

if a function calls a function and there both dead because no one is calling the first function, only the first one will be called dead by the tool because that dead function is calling it. how about adding recursive mode after a first scan all the presumed dead function will be marked as an comment and the function will run again until no dead code will find. after that all the files will need to be revert back of course.
I've attached an example in witch only func2 is detected as dead although other function are dead as well.

Comments (6)

  1. Jendrik Seipp

    You're right, vulture doesn't detect that func3 is also dead code. I think a simpler solution to this problem is however, to add to the documentation that subsequent vulture runs after deleting dead code may discover more dead code.

  2. Jendrik Seipp

    Well, laziness is a programmer's virtue ;) The problem is, that you'll never find all dead code if you don't remember who called who. If func2 calls func3 and noone else calls either, they won't be detected even if you search repeatedly.

    The proper solution (one that also detects cycles) would be to construct a call graph and report nodes that are not reachable from the module-level as dead code. For your example:

    module-level -> func1

    func2 -> func3 -> temp

    Thus func2, func3 and temp are dead code.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.