Git Product home page Git Product logo

traceroute's Introduction

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 (trunk)

  • Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x

Install

Put this line in your Gemfile:

gem 'traceroute'

Then bundle:

% bundle

Usage

Just run the following command in your Rails app directory.

% rake traceroute

If 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])
  end

  def index2
  end

  def show
    @user = User.find(params[:id])
  end
end

Running the Rake task will print something like this for you:

Unused routes (3):
  users#create
  users#new
  catalog#purchase
Unreachable action methods (1):
  users#index2

OMG super helpful, isn’t it?

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.

Notes

Routes prefix with `rails/` are ignored. These are generated by rails in development mode. We don't want to fail the build on these.

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 © 2011 Akira Matsuda. See LICENSE.txt for further details.

traceroute's People

Contributors

amatsuda avatar distributedlife avatar damirsvrtan avatar ogawaso avatar dmitryv avatar

Watchers

john-kuo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.