Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 !

like image 328
Renan Ranelli Avatar asked Apr 14 '15 17:04

Renan Ranelli


1 Answers

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.

like image 168
Jorge de los Santos Avatar answered Oct 06 '22 14:10

Jorge de los Santos