Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amatsuda/traceroute
A Rake task gem that helps you find the unused routes and controller actions for your Rails 3+ app
https://github.com/amatsuda/traceroute
Last synced: about 15 hours ago
JSON representation
A Rake task gem that helps you find the unused routes and controller actions for your Rails 3+ app
- Host: GitHub
- URL: https://github.com/amatsuda/traceroute
- Owner: amatsuda
- License: mit
- Created: 2011-05-05T18:28:20.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T19:19:53.000Z (about 1 year ago)
- Last Synced: 2024-12-05T17:08:37.702Z (8 days ago)
- Language: Ruby
- Homepage:
- Size: 89.8 KB
- Stars: 901
- Watchers: 18
- Forks: 38
- Open Issues: 16
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
- awesome-ruby - Traceroute - A Rake task gem that helps you find the dead routes and actions for your Rails 3+ app (Code Analysis and Metrics)
README
= Traceroute
A Rake task that helps you find dead routes and unused actions in your Rails 3+ app.
== Features
This Rake task investigates your Rails application's routes definition, then shows you the unused routes and unreachable action methods.
== Supported versions
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1 (trunk)
* Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x, 5.0.x, 5.1.x, 5.2.x, 6.0, 6.1, 7.0 (master)
== Install
Put this line in your Gemfile:
gem 'traceroute'Then bundle:
% bundle== Usage
Just run the following command in your Rails app directory.
% rake tracerouteIf you want the rake task to fail when errors are found.
% FAIL_ON_ERROR=1 rake traceroute
== What's gonna happen then?
Consider you have the following routes.rb and a controller:
# config/routes.rb
YourRailsApp::Application.routes.draw do
resources :users, :only => [:index, :show, :new, :create]
match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
end# app/controllers/users_controller.rb
class UsersController < ApplicationController
def index
@users = User.page(params[:page])
enddef index2
enddef show
@user = User.find(params[:id])
end
endRunning the Rake task will print something like this for you:
Unused routes (3):
users#create
users#new
catalog#purchase
Unreachable action methods (1):
users#index2OMG super helpful, isn't it?
== How do I tell it to ignore routes?
Some gems out there that inject routes or actions into our app for testing. Jasmine-Rails does this. They can give you false negatives when running this in development mode. It can be useful to ignore said routes or actions.
Create a .traceroute.yaml (or .traceroute.yml or .traceroute) file in your root directory.
# .traceroute.yaml
ignore_unreachable_actions:
- ^jasmine_rails\/
ignore_unused_routes:
- ^users#indexBoth yaml headers accept a list of regexes.
== FAQ
Q: It makes a fuss over the default route at the very bottom. WTF?
A: Please do not use that. Did you read the comment in your routes.rb? Actually this task will help you a lot to remove that evil route.Q: "command not found: traceroute" Did you mean: tracert
A: I'm afraid you're using the wrong operating system.== Questions, Feedback
Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇3☇3☇3
== Contributing to Traceroute
* Fork, patch, then send me a pull request.
== Copyright
Copyright (c) 2011 Akira Matsuda. See MIT-LICENSE file for further details.