Sha256: bb5820e5b05e993fbf2cea95aa4e1b35df8ef7a7f5ba8459baea2ac9d47ebfff

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 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(options = {}) #: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 }, RUBY_VERSION =~ /1\.8/ ? 0 : -1)
          end

        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/rails/instance_var_in_partial_check.rb