Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 737
professormeowingtons Avatar asked Jun 25 '13 17:06

professormeowingtons


People also ask

Where is the unused code in Visual Studio?

To find unused members with a Code Analysis Ruleset, from the Visual Studio menu select File -> New -> File… -> General -> Code Analysis Rule Set. Uncheck all the rules. There are many rules we don't care about right now – and some we probably won't ever care about.

How do I find unused codes in Python?

Vulture - Find dead code. Vulture finds unused code in Python programs. This is useful for cleaning up and finding errors in large code bases. If you run Vulture on both your library and test suite you can find untested code.


1 Answers

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.

like image 127
vgoff Avatar answered Oct 21 '22 14:10

vgoff