Sha256: 77713c5bc14d2d27bf33387d78988377881e649514d6df93cb532a70c8f66870

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

require 'rails_best_practices/checks/check'

module RailsBestPractices
  module Checks
    # Check config/routes to make sure not use default route that rails generated.
    #
    # Implementation: compare route sentence to see if it is equal to rails default route.
    class NotUseDefaultRouteCheck < Check
      
      def interesting_nodes
        [:call]
      end
      
      def interesting_files
        /config\/routes.rb/
      end
      
      def evaluate_start(node)
        if node == s(:call, s(:lvar, :map), :connect, s(:arglist, s(:str, ":controller/:action/:id"))) or
           node == s(:call, s(:lvar, :map), :connect, s(:arglist, s(:str, ":controller/:action/:id.:format"))) or
           node == s(:call, nil, :match, s(:arglist, s(:str, ":controller(/:action(/:id(.:format)))")))
          add_error "not use default route"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_best_practices-0.4.2 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.4.1 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.4.0 lib/rails_best_practices/checks/not_use_default_route_check.rb