13

What is a good way to find methods in a that are not being called anymore? I'm in the process of refactoring a large Rails application and the worst thing you can find is code that is not being used anymore.

Ibrahim Muhammad
  • 2,808
  • 4
  • 29
  • 39
  • yeah, if I get a list of all methods for all classes defined in my application, could possibly grep them to see if they exist in other files. – Ibrahim Muhammad Dec 20 '12 at 20:34
  • possible duplicate of [Find unused code in a Rails app](http://stackoverflow.com/questions/9735307/find-unused-code-in-a-rails-app) – Jared Beck May 02 '14 at 20:59

1 Answers1

8

This is a tricky problem without an easy, always-right answer. Some places to start include:

  1. Sweep unused code into the dustbin with rcov
  2. Performance Testing Ruby on Rails Applications
  3. Find unused code in a Rails app

The biggest issue is that unused code and unreachable code aren't the same things. Just because code isn't exercised routinely in production doesn't really mean it's dead code that should be removed. It may be there for a reason---just not one that comes up often.

bigtex777
  • 1,150
  • 10
  • 15
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199