Sha256: f1ebe606dd18c6687412e768e958152b0c3a4025bcd143588413ec57dfdd850a

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
require 'rails_best_practices/reviews/review'

module RailsBestPractices
  module Reviews
    # Review 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:
    #
    # Review process:
    #   check all instance variable in partial view files,
    #   if exist, then they should be replaced with local variable
    class ReplaceInstanceVariableWithLocalVariableReview < Review
      def url
        "http://rails-bestpractices.com/posts/27-replace-instance-variable-with-local-variable"
      end

      def interesting_nodes
        [:ivar]
      end

      def interesting_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 start_ivar(node)
        add_error "replace instance variable with local variable"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rails_best_practices-0.10.1 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.10.0 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-raydog153-0.9.1 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.9.0 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.8.2 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.8.1 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.8.0 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.5 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.4 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.3 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.2 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.1 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.7.0 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
rails_best_practices-0.6.7 lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb