lib/rubocop/cop/style/and_or.rb in rubocop-0.81.0 vs lib/rubocop/cop/style/and_or.rb in rubocop-0.82.0

- old
+ new

@@ -95,16 +95,16 @@ return correct_other(node, corrector) if node.comparison_method? return unless correctable_send?(node) corrector.replace(whitespace_before_arg(node), '(') - corrector.insert_after(node.last_argument.source_range, ')') + corrector.insert_after(node.last_argument, ')') end def correct_setter(node, corrector) - corrector.insert_before(node.receiver.source_range, '(') - corrector.insert_after(node.last_argument.source_range, ')') + corrector.insert_before(node.receiver, '(') + corrector.insert_after(node.last_argument, ')') end # ! is a special case: # 'x and !obj.method arg' can be auto-corrected if we # recurse down a level and add parens to 'obj.method arg' @@ -122,12 +122,11 @@ end def correct_other(node, corrector) return if node.source_range.begin.is?('(') - corrector.insert_before(node.source_range, '(') - corrector.insert_after(node.source_range, ')') + corrector.wrap(node, '(', ')') end def correctable_send?(node) !node.parenthesized? && node.arguments? && !node.method?(:[]) end @@ -135,10 +134,10 @@ def whitespace_before_arg(node) begin_paren = node.loc.selector.end_pos end_paren = begin_paren # Increment position of parenthesis, unless message is a predicate # method followed by a non-whitespace char (e.g. is_a?String). - end_paren += 1 unless node.source =~ /\?\S/ + end_paren += 1 unless /\?\S/.match?(node.source) range_between(begin_paren, end_paren) end end end end