stevec
stevec

Reputation: 52588

How to tell if a route/method/view ever gets used?

I'm attempting to clean up any routes, controller actions, and views that literally never get used in an application (that is, they'd be impossible to visit unless a user happened to guess the route).

(these sometimes appear because I think I'll need it, so set up the route, action, and view, then work takes a different direction and it doesn't get used)

The problem is how do I confidently tell if a certain route is ever linked to in an app?

What I already know

If the route looked like this

# routes.rb

'payments-setup-status' => 'user#payments_setup_status'

Then I could search the entire repository for payments-setup-status and for payments_setup_status_url and payments_setup_status_path. If I find no links to it, then assume it's unused anywhere in the app.

I am not sure what else I could do, or if there is some more 'intelligent' way of figuring out which routes/actions/views are not used in an application?

Upvotes: 0

Views: 124

Answers (1)

stevec
stevec

Reputation: 52588

A suggestion offered in another forum:

  • Use coverband to find out which code in your app gets used and which code doesn't.
  • If your app is in production, run coverband and view which code doesn't get run
  • If your app isn't in production yet, run coverband in development, navigate around the app to get some idea about which code isn't getting used

Upvotes: 1

Related Questions