Sha256: de34b3aace9a16db2f0521d6193067808c71eeece913d2d3145c4c4d87e01df0

Contents?: true

Size: 852 Bytes

Versions: 3

Compression:

Stored size: 852 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
        #
        # * partials
        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

3 entries across 3 versions & 2 rubygems

Version Path
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb