Sha256: 041b6dab9be927cee802034211191d167a77370885eacd8aa853f17e8cc65a1e

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 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 and node.arguments.size > 1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-0.3.22 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb
rails_best_practices-0.3.21 lib/rails_best_practices/checks/keep_finders_on_their_own_model_check.rb