123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::CheckAssignment

Overview

Common functionality for checking assignment nodes.

Class Method Summary

Instance Method Summary

Class Method Details

.extract_rhs(node) (mod_func)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 29

def extract_rhs(node)
  if node.casgn_type?
    _scope, _lhs, rhs = *node
  elsif node.op_asgn_type?
    _lhs, _op, rhs = *node
  elsif node.call_type?
    rhs = node.last_argument
  elsif node.assignment?
    _lhs, rhs = *node
  end

  rhs
end

Instance Method Details

#on_and_asgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 17

alias on_and_asgn on_lvasgn

#on_casgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 13

alias on_casgn    on_lvasgn

#on_cvasgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 11

alias on_cvasgn   on_lvasgn

#on_gvasgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 12

alias on_gvasgn   on_lvasgn

#on_ivasgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 10

alias on_ivasgn   on_lvasgn

#on_lvasgn(node) Also known as: #on_ivasgn, #on_cvasgn, #on_gvasgn, #on_casgn, #on_masgn, #on_op_asgn, #on_or_asgn, #on_and_asgn

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 7

def on_lvasgn(node)
  check_assignment(node, extract_rhs(node))
end

#on_masgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 14

alias on_masgn    on_lvasgn

#on_op_asgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 15

alias on_op_asgn  on_lvasgn

#on_or_asgn(node)

Alias for #on_lvasgn.

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 16

alias on_or_asgn  on_lvasgn

#on_send(node)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 19

def on_send(node)
  rhs = extract_rhs(node)

  return unless rhs

  check_assignment(node, rhs)
end