Renan Ranelli
Renan Ranelli

Reputation: 414

Is it possible to discover which classes are not used in a Ruby on Rails application?

In our project we had some "forgotten" classes lying around for quite some time.

Those classes were substituted by other ones but we forgot to delete them. Is there some automated way/tool to discover which classes are not being used in a Ruby {on Rails,} application?

Thanks !

Upvotes: 6

Views: 294

Answers (1)

Jorge de los Santos
Jorge de los Santos

Reputation: 4643

This question has been made a lot of times, but the best answers are compiled in here:

Find unused code in a Rails app

I, personally, liked the log parsing:

https://stackoverflow.com/a/14161807

But in any case you can create your own logger extending ActiveRecord::Base to create an observer which stores in a database the most used modules. After a prudential time, you will be able to reverse find models that are not called even once.

There are other profesional tools (paid) that measures your app behaviour:

http://newrelic.com/

I've used this one in a project and did a great working measuring the controller usage. You might find it useful.

Upvotes: 4

Related Questions