lib/rubocop/cop/style/if_unless_modifier.rb in rubocop-0.36.0 vs lib/rubocop/cop/style/if_unless_modifier.rb in rubocop-0.37.0
- old
+ new
@@ -22,19 +22,12 @@
# discard ternary ops, if/else and modifier if/unless nodes
return if ternary_op?(node)
return if modifier_if?(node)
return if elsif?(node)
return if if_else?(node)
- return if chained?(node)
+ return if node.chained?
return unless fit_within_line_as_modifier_form?(node)
add_offense(node, :keyword, message(node.loc.keyword.source))
- end
-
- def chained?(node)
- # Don't register offense for `if ... end.method`
- return false if node.parent.nil? || !node.parent.send_type?
- receiver = node.parent.children[0]
- node.equal?(receiver)
end
def parenthesize?(node)
# Parenthesize corrected expression if changing to modifier-if form
# would change the meaning of the parent expression