How to find all unused code in Ruby on Rails

I inherited a Rails 2.3 application that does not have a robust test suite. There are many tests, but unfortunately many tests are tested on old, unused models, controllers, and views.

Does anyone have a reliable idea of ​​how I can check which models, controllers, views, helpers, etc. completely unused, and also study those used by ARE, and see which features are not specifically used?

+6
source share
3 answers

You can look at this answer, and maybe some of the answers below: fooobar.com/questions/94248 / ...

I would probably finish logging the methods that you have and run your code through paths and everything that is not listed in the log can be checked to make sure that it is not really used.

+1
source

RCov or SimpleCov wo n't do it what you want?

+1
source

You can try using RubyMine, the Rails IDE, to find unused code. Try to find method names and the like. It has been a while since I used it, so I don’t know if it will have highlighting of unused methods.

Alternatively, you can try several bash commands (grep / ack / find) to search for snippets of code.

+1
source

Source: https://habr.com/ru/post/948085/


All Articles