Sha256: 5f3a4c2d014983ae09797b629e03731c52fa96a08b0d40963cd14e86f9357e16

Contents?: true

Size: 781 Bytes

Versions: 44

Compression:

Stored size: 781 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")))
          add_error "not use default route"
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
rails_best_practices-0.3.27 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.26 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.25 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.24 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.23 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.22 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.21 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.20 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.19 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.18 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.17 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.16 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.15 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.14 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.13 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.12 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.11 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.10 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.9 lib/rails_best_practices/checks/not_use_default_route_check.rb
rails_best_practices-0.3.8 lib/rails_best_practices/checks/not_use_default_route_check.rb