1. Jendrik Seipp
  2. vulture
  3. Issues


Issue #2 wontfix

dead code calling other dead code

Anonymous 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 repo owner

    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 repo owner

    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