Sha256: 3408141415a368c57202c88926a8b29b3f5a57c6bab5393933265837aa3a1f2a
Contents?: true
Size: 796 Bytes
Versions: 3
Compression:
Stored size: 796 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop # 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." module SafeAssignment def safe_assignment?(node) return false unless node.type == :begin return false unless node.children.size == 1 child = node.children.first case child.type when :send _receiver, method_name, _args = *child method_name.to_s.end_with?('=') when *Util::EQUALS_ASGN_NODES true else false end end def safe_assignment_allowed? cop_config['AllowSafeAssignment'] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.34.2 | lib/rubocop/cop/mixin/safe_assignment.rb |
rubocop-0.34.1 | lib/rubocop/cop/mixin/safe_assignment.rb |
rubocop-0.34.0 | lib/rubocop/cop/mixin/safe_assignment.rb |