Sha256: 3478b243d090d495f243612a6a2042edf442d9d14b9c477da78a733fabb481bc

Contents?: true

Size: 993 Bytes

Versions: 2

Compression:

Stored size: 993 Bytes

Contents

# encoding: utf-8
require 'rails_best_practices/checks/check'

module RailsBestPractices
  module Checks
    # Check a partail view file to make sure there is no instance variable.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/27-replace-instance-variable-with-local-variable.
    #
    # Implementation:
    #
    # Prepare process:
    #   none
    #
    # Review process:
    #   check all instance variable in partial view files,
    #   if exist, then they should be replaced with local variable
    class ReplaceInstanceVariableWithLocalVariableCheck < Check

      def interesting_review_nodes
        [:ivar]
      end

      def interesting_review_files
        PARTIAL_VIEW_FILES
      end

      # check ivar node in partial view file,
      # it is an instance variable, and should be replaced with local variable.
      def review_start_ivar(node)
        add_error "replace instance variable with local variable"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-0.6.5 lib/rails_best_practices/checks/replace_instance_variable_with_local_variable_check.rb
rails_best_practices-0.6.1 lib/rails_best_practices/checks/replace_instance_variable_with_local_variable_check.rb