Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

ruby on rails - 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?

question from:https://stackoverflow.com/questions/65886533/how-to-tell-if-a-route-method-view-ever-gets-used

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...