Code Monkey home page Code Monkey logo

rails-route-checker's Introduction

RailsRouteChecker

A linting tool that helps you find any routes defined in your routes.rb file that don't have a corresponding controller action, and find any _path or _url calls that don't have a corresponding route in the routes.rb file.

Installation

Add this line to your application's Gemfile:

gem 'rails-route-checker', require: false

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-route-checker

Usage

Run rails-route-checker from your command line while in the root folder of your Rails application.

You may also specify a custom config file using the -c or --config flag. By default, the config file is search for at .rails-route-checker.yml. More information on the config file can be found below.

rails-route-checker will scan controllers along with Haml and ERb view files.

bundle exec rails-route-checker

The following 1 routes are defined, but have no corresponding controller action.
If you have recently added a route to routes.rb, make sure a matching action exists in the controller.
If you have recently removed a controller action, also remove the route in routes.rb.
 - oauth_apps/authorizations#show


The following 1 url and path methods don't correspond to any route.
 - app/controllers/application_controller.rb:L707 - call to potential_url

Config file

By default, rails-route-checker will look for a config file .rails-route-checker.yml. However, you can override this by using the --config command line flag.

The following is an example config file:

# Any controllers you don't want to check
ignored_controllers:
  - oauth_apps/authorizations

# Any paths or url methods that you want to be globally ignored
# i.e. confirmation_url and confirmation_path will never be linted against
ignored_paths:
  - confirmation

# For specific files, ignore specific path or url calls
ignored_path_whitelist:
  app/controllers/application_controller.rb:
      - potential_url
  app/views/my_controller/my_view.haml:
    - paginate_url

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Feel free to fork this repo and open a PR. Alongside your changes, please add a line to CHANGELOG.md.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Rails::Route::Checker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

rails-route-checker's People

Contributors

daveallie avatar ghiculescu avatar deecewan avatar palkan avatar

Watchers

James Cloos 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.