Sha256: 95fa3d54fe986015fde7733d49651d9c0aaa4a147e1401b8825e1b0619db2523

Contents?: true

Size: 827 Bytes

Versions: 4

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for checking assignment nodes.
    module CheckAssignment
      def on_lvasgn(node)
        check_assignment(node, extract_rhs(node))
      end
      alias on_ivasgn   on_lvasgn
      alias on_cvasgn   on_lvasgn
      alias on_gvasgn   on_lvasgn
      alias on_casgn    on_lvasgn
      alias on_masgn    on_lvasgn
      alias on_op_asgn  on_lvasgn
      alias on_or_asgn  on_lvasgn
      alias on_and_asgn on_lvasgn

      def on_send(node)
        return unless (rhs = extract_rhs(node))

        check_assignment(node, rhs)
      end

      module_function

      def extract_rhs(node)
        if node.call_type?
          node.last_argument
        elsif node.assignment?
          node.expression
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-1.69.2 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-1.69.1 lib/rubocop/cop/mixin/check_assignment.rb
rubocop-1.69.0 lib/rubocop/cop/mixin/check_assignment.rb