Sha256: a0161d948f3b54d7cd81042099c789dcb1fd76a6227a77b18cb4a0690a18890f

Contents?: true

Size: 940 Bytes

Versions: 22

Compression:

Stored size: 940 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    # Common functionality for checking assignment nodes.
    module CheckAssignment
      TYPES = Util::ASGN_NODES - [:casgn, :op_asgn]
      TYPES.each do |type|
        define_method("on_#{type}") do |node|
          _lhs, rhs = *node
          check_assignment(node, rhs)
        end
      end

      def on_casgn(node)
        _scope, _lhs, rhs = *node
        check_assignment(node, rhs)
      end

      def on_op_asgn(node)
        _lhs, _op, rhs = *node
        check_assignment(node, rhs)
      end

      def on_send(node)
        _receiver, method_name, *_, rhs = *node

        # we only want to indent relative to the receiver
        # when the method called looks like a setter
        return unless method_name.to_s.end_with?('=')

        # This will match if, case, begin, blocks, etc.
        check_assignment(node, rhs) if rhs.is_a?(AST::Node)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/check_assignment.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.34.2 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.34.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.34.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.33.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.32.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.32.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.31.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.30.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.30.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.29.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.29.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.28.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.27.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.27.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.26.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.26.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.25.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-0.24.1 lib/rubocop/cop/mixin/check_assignment.rb