I'm looking for a tool that traverses Java source code files starting with some class that I can pick and gives me a total of all lines or code that are needed to successfully compile the project (excluding comments, blank lines, and lines in methods or classes that are never used (directly or indirectly) or that declare variables that are never used). The tool should be able to traverse into libraries as well if I provide the source-code.

  • Never used is a tricky concept, if 0 is easy but if politician_truthful you might know is never but would a tool? – Steve Barnes Aug 13 '17 at 4:38
  • @SteveBarnes It would definitely be a bit much to ask it to try and determine all possible actual code-paths. That would probably be as intractable as the halting problem. I was just looking for something that prunes the code before counting. I.e. doesn't count any classes, fields, or methods that can never be reached, no matter what any of the if-conditions evaluate to (ignoring classes, fields, and methods reached via reflection is fine, of course). Basically exactly what ProGuard does. – Markus A. Aug 13 '17 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.