Sha256: 6bfef89230828ef671d927463bcea24e26db7e4ac59f6b85df1de499dbbbe662

Contents?: true

Size: 862 Bytes

Versions: 5

Compression:

Stored size: 862 Bytes

Contents

require 'simplabs/excellent/checks/base'

module Simplabs

  module Excellent

    module Checks

      module Rails

        # This check reports partials that use instance variables. Using instance variables in partials couples the partial to the controller action or
        # template that includes the partial and that has to define the instance variable.
        #
        # ==== Applies to
        #
        # * instance variables
        class InstanceVarInPartialCheck < Base

          def initialize #:nodoc:
            super
            @interesting_nodes = [:ivar]
            @interesting_files = [/^_.*\.erb$/]
          end

          def evaluate(context) #:nodoc:
            add_warning(context, 'Instance variable {{variable}} used in partial.', { :variable => context.full_name })
          end

        end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb