Find Dead Rails Code
Asked Answered
T

1

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.

Theodoratheodore answered 20/12, 2012 at 20:19 Comment(2)
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.Theodoratheodore
possible duplicate of Find unused code in a Rails appFrightful
S
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.

Smriti answered 20/12, 2012 at 20:48 Comment(1)
Thanks, I was looking for something like how rails_best_practices shows unused methods, didn't realize it had that functionalityTheodoratheodore

© 2022 - 2024 — McMap. All rights reserved.