Skip to content

Dead Code and Unused Asset Discovery

This app is large (~1,700+ partials, 1,000+ helper methods, 200+ routes). One-off manual checks only scratch the surface. Use the tools below for broader cleanup.

  • Dead partials: app/views/opportunities/_opportunity.html.erb, app/views/stores/_warehouse_package.html.erb
  • Dead route: GET /customers/view_by_rep (no controller action existed)
  • Orphan views: customers/view_by_rep.js.erb, customers/_view_by_rep.html.erb
  • Dead helper methods: ReportsHelper#opp_before, #opp_after, #order_before, #order_after, #first_order
GemPurposeHow to run
tracerouteFinds routes with no controller action (or no view)Use the project script below; or mise exec -- bundle exec traceroute if the gem exposes a CLI

Partials: No reliable gem for unused partials in this app (render partial: '/foo', dynamic names, and presenters produce huge false-positive lists). Use manual review, production render logging, or custom scripts if needed.

script/unused_routes.rb uses traceroute-style logic and checks for presence of views. It requires a full Rails load (eager_load).

Terminal window
mise exec -- ruby script/unused_routes.rb

Note: The script was updated to use require_relative '../config/environment'. If eager_load fails (e.g. missing constant in dev), run in an environment where the app loads cleanly or temporarily skip eager_load for a lighter check.

Many gems in the Gemfile are require: false and only loaded when used. To find gems that are never required:

  • bumbler (dev, optional): Uncomment bumbler in the Gemfile, then mise exec -- bundle exec bumbler — profiles gem load times.
  • Manual check: search the codebase for require '<gem_name>' or require "<gem_name>" and for the gem’s main namespace (e.g. Crisp:: for crisp-api).

Possible unused gem (verify before removing): crisp-api — no require 'crisp_api' or Crisp:: usage found; Crisp chat is used via frontend JS and config only. Confirm in your codebase before dropping.

  • Helpers: There is no built-in “unused helper method” gem. Options: grep for each helper method name across app/views and app/helpers, or use a static analysis tool that understands Rails helpers.
  • Partials: Same—dynamic render and leading-slash paths defeat naive scanners; grep and feature-by-feature review are more trustworthy.
  • After large refactors or before a major release.
  • Periodically (e.g. quarterly) to keep the codebase lean.
  • Before removing a feature, run discovery to see related dead code.