How to find unused methods in a Ruby application?

I have a Ruby application with a lot of classes / modules, and some of them are not used. Is there an easy way to find out what?

I thought to make a profile, and then work with it. Any other ideas?

+8
ruby refactoring
Jun 02 2018-10-02T00:
source share
2 answers

A cover tool such as rcov may help.

https://github.com/relevance/rcov

When 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 might be the smell of code that also needs refactoring.

+6
Jun 02 '10 at 2:09 p.m.
source share

You can put raise (or raise Exception if you do not want it to be caught) before the start of the suspicious method. If nothing breaks, then it cannot be used (either this or something that catches exceptions).

+2
Jun 02 '10 at 23:52
source share



All Articles