views:

89

answers:

2

I have a Ruby app with a lot of classes/modules, and some of them are not used. Is there an easy way of finding out which?

I was thinking to do a profile, and then work with it's output. Any other ideas?

+4  A: 

A coverage tool, like rcov might help.

http://eigenclass.org/hiki/rcov

As you find methods that are not covered by tests, you should write tests for them or find out if they are used at all.

Removing unused methods is part of refactoring, if you have too many classes that can be a code smell that needs refactored also.

Freiheit
If you're worried about certain branches not being covered, you can also try heckle.
Andrew Grimm
+1  A: 

You can put raise (or raise Exception if you don't want it caught) to the start of the suspect method. If nothing breaks, then it might not be in use (either that, or something's catching the exceptions).

Andrew Grimm