123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::SafeAssignment

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Macros
Defined in: lib/rubocop/cop/mixin/safe_assignment.rb

Overview

Common functionality for safe assignment. By safe assignment we mean putting parentheses around an assignment to indicate "I know I’m using an assignment as a condition. It’s not a mistake."

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#safe_assignment_allowed?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/safe_assignment.rb', line 22

def safe_assignment_allowed?
  cop_config['AllowSafeAssignment']
end

Instance Method Details

#empty_condition?(node) (private)

[ GitHub ]

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

def_node_matcher :empty_condition?, '(begin)'

#safe_assignment?(node) (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/safe_assignment.rb', line 20

def_node_matcher :safe_assignment?, '(begin {equals_asgn? #setter_method?})'

#setter_method?(node) (private)

[ GitHub ]

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

def_node_matcher :setter_method?, '[(call ...) setter_method?]'