professormeowingtons
professormeowingtons

Reputation: 3514

How to find all unused code in Ruby on Rails

I've inherited a Rails 2.3 app, which lacks a solid test suite. There is a fair amount of testing, but unfortunately, many of the tests test against old, unused models, controllers, and views.

Does anyone have a solid idea of how I might go about testing which models, controllers, views, helpers, etc. are completely unused, as well as look into the ones that ARE used and see which functions specifically are not used?

Upvotes: 6

Views: 3616

Answers (3)

vgoff
vgoff

Reputation: 11323

You can look at this answer, and perhaps some of the other answers listed: https://stackoverflow.com/a/9788511/485864

I would probably end up logging the methods that you have, and run your code through the paths and anything not listed in the log, may be examined to see if it is indeed not used.

Upvotes: 1

renatojf
renatojf

Reputation: 744

You can try to use RubyMine, a Rails IDE, to search for unused code. Try searching for method names and stuff like that. It's been a while since I used it so I dunno if it will have a highlight on unused methods.

Also, you can try some bash commands(grep/ack/find) to search for the code snippets.

Upvotes: 1

Hauleth
Hauleth

Reputation: 23586

RCov or SimpleCov won't do this what you want?

Upvotes: 1

Related Questions