Repository is archived
No commit activity in last 3 years
No release in over 3 years
Uses exports of live controllers to generate unused routes. Uses the same formatting as newrelic controller exports.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0
~> 3.0

Runtime

>= 3.0.0
 Project Readme

CircleCI Code Climate Test Coverage

RakeUnusedRoutes

Identify unused routes within your rails routes.rb file by reading in a csv file of all controllers hit within a given time period. The csv file can most easily be generated with New Relic.

This gem is inspired by newrelic_route_check

Installation

Add this line to your application's Gemfile:

gem 'rake_unused_routes'

And then execute:

$ bundle

Usage

In order to see unused routes, we need an export of all controller actions that are still in use. An easy way of generating the export is with either the basic NewRelic RPM or NewRelic Insights.

From a NewRelic RPM Web Transactions CSV

Generate the CSV

The easiest way to generate a CSV file is by exporting all controllers from the all transactions page within newrelic. To get there:

  1. Navigate to Transactions
  2. Select "Last 7 Days ending now" within time picker
  3. Pick type Web
  4. Click "Show all transactions table"
  5. Click "Export as CSV"

New Relic Transactions

Copy exported file to $RAILS_ROOT/tmp/controller_summary.csv

Generate unused_routes

Run:

rake unused_routes

From a NewRelic Insights export

The advantage of using NewRelic Insights export is that dependening on your retention policies, Insights can generate a report for a much great length of time than 7 days. Our current NewRelic policies allow for pulling usage data from 9 weeks ago.

Generate the CSV

Navigate to Insights and run the following query:

SELECT count(*) 
from Transaction 
where transactionSubType ='Controller' 
facet name 
since 9 weeks ago 
limit 1000

Export the results to a csv file:

Insight Export to CSV

Copy the results to $RAILS_ROOT/tmp/insights_controllers.csv .

Then run:

rake unused_routes:from_insights

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. 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

Bug reports and pull requests are welcome on GitHub at https://github.com/viewthespace/rake_unused_routes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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