Sha256: c77b62f6820fc80d50bdd7de2c8b9c6ee989fb5d8d1fabdbd0a033a016d84564

Contents?: true

Size: 650 Bytes

Versions: 24

Compression:

Stored size: 650 Bytes

Contents

require 'rails_best_practices/checks/check'

module RailsBestPractices
  module Checks
    # Check a model to make sure finders are on their own model.
    #
    # Implementation: check if :find is called by other model.
    class KeepFindersOnTheirOwnModelCheck < Check
      
      def interesting_nodes
        [:call]
      end

      def interesting_files
        MODLE_FILES
      end

      def evaluate_start(node)
        add_error "keep finders on their own model" if others_finder?(node)
      end

      private

      def others_finder?(node)
        node.message == :find and node.subject.node_type == :call
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rails_best_practices-0.3.20 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.19 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.18 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.17 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.16 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.15 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.14 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.13 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.12 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.11 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.10 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.9 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.8 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.7 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.6 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.5 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.4 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.3 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.2 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.1 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb