Module: RuboCop::Cop::CheckAssignment
- Included in:
- Layout::AssignmentIndentation, Layout::ElseAlignment, Layout::EndAlignment, Layout::IndentationWidth, Layout::MultilineAssignmentLayout, Layout::RedundantLineBreak
- Defined in:
- lib/rubocop/cop/mixin/check_assignment.rb
Overview
Common functionality for checking assignment nodes.
Class Method Summary collapse
Instance Method Summary collapse
- #on_lvasgn(node) ⇒ Object (also: #on_ivasgn, #on_cvasgn, #on_gvasgn, #on_casgn, #on_masgn, #on_op_asgn, #on_or_asgn, #on_and_asgn)
- #on_send(node) ⇒ Object
Class Method Details
.extract_rhs(node) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 27 def extract_rhs(node) if node.call_type? node.last_argument elsif node.assignment? node.expression end end |
Instance Method Details
#on_lvasgn(node) ⇒ Object Also known as: on_ivasgn, on_cvasgn, on_gvasgn, on_casgn, on_masgn, on_op_asgn, on_or_asgn, on_and_asgn
7 8 9 |
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 7 def on_lvasgn(node) check_assignment(node, extract_rhs(node)) end |
#on_send(node) ⇒ Object
19 20 21 22 23 |
# File 'lib/rubocop/cop/mixin/check_assignment.rb', line 19 def on_send(node) return unless (rhs = extract_rhs(node)) check_assignment(node, rhs) end |