• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tool to clean source code?

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a project which is huge, has a lot of code (java, ejbs, servlets and jsps). This project is old and several different people worked on it at different stages (I am saying that so that I don't get suggestions like 'change your design/don't make mistakes at the beginning etc.').
Is there any tool/utility that can help me find all unused methods in all the classes under project, so that I could get rid of them? In addition, it would be great if the tool could tell me that I can change modifier of a method to private/protected instead of keeping it public as it is not used outside.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's difficult to do this reliably, since the introspection mechanism can be used to build up a method name from string functions. And, of course, if you're using library jars, there's probably going to be hundreds of unused methods which would have to be ignored, since "unused" doesn't mean "useless".

I generally just flag everything suspect as private and see what doesn't compile, but there is a code improvement tool I used to use. I think it was called something like "Bug Buddy". I don't know if it can detect unused code, but it was pretty good at rooting out a whole bunch of potential problems.

I'd forgotten all about it. I need to find it again.
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. I will take a look at tool you mentioned.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse has a feature: Source / Clean Up, which can do this in a limited way.
 
reply
    Bookmark Topic Watch Topic
  • New Topic