Sha256: 65ff5828b0a7a3441b1338db6e120f7943d76f4844e985cf63da731b88a5cc93

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 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_contexts = [Parsing::IvarContext]
            @interesting_files = [/^_.*\.erb$/]
          end

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

        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excellent-1.6.0 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb