seattlerb/debride

Results of running debride on a commercial Rails app

Closed this issue · 7 comments

Moved here from #12 at @zenspider's request. I'm not looking for any changes in debride, just passing along results.

Rails 3 app, will turn 8 years old on May 9, ~200K LOC, ~91% covered by tests, most unused methods revealed by lack of test coverage already removed from production (non-test) code. We don't measure coverage of test code so it would not be surprising to find some unused methods there.

debride (actually debride -r app lib) found ~1300 possibly unused methods. I had to ignore the output for Rails controllers and helpers, since only our logs know whether actions are used or unused, and debride doesn't detect method usages in erb. That left lib, models and what Rails 4 would call concerns (classes supporting controllers and models), ~800 possibly unused methods. It took me a couple of hours (in the air between Atlanta and SF) to review them. I found ~30 unused methods, almost all tested but not used in actual application code. A few unused methods were untested one-liners that hadn't stood out in coverage.

I also found around a dozen methods in production code that were only used in test code. I inlined a few but otherwise ignored them; a more exacting team might take the time to move them to test code.

debride found ~50 unused methods in our test code, and about half were unused.

Total lines of code removed (unused production code, tests of that unused production code, and unused test code): ~1200. No effect on coverage, since almost all of the removed code was tested or was in test code, which we don't include in the coverage measurement.

debride doesn't detect method usages in erb.

I'm curious what you mean by this. Did you have the debride-erb plugin installed?

No, I was not aware of that plugin. I'll try it soon.

Can you get me a healthy hunk of your logs? I'd like to provide a tool that can generate a whitelist. Doing it from rake routes means you have false positives. I'd rather have false negatives that can be fixed by feeding it more logs.

OK... Forget the log thing. Try this:

https://gist.github.com/zenspider/d6390a81a11c9501bdfe

Run it like so:

% rake routes > routes.txt
% ./rails_whitelist.rb routes.txt production.log | sort -u > whitelist.txt

then run debride using that whitelist. Lemme know if it improves things.

Anything? I would love to see if we can get this improved.

Added the script to debride...

I've run this on a number of commercial rails apps now. With the whitelisting it seems to work pretty well. I'm considering this issue handled (esp since I haven't heard back from the OP). Closing.

Please open a new issue if something wasn't handled.