lib/rubocop/cop/lint/safe_navigation_chain.rb in rubocop-0.75.1 vs lib/rubocop/cop/lint/safe_navigation_chain.rb in rubocop-0.76.0
- old
+ new
@@ -40,24 +40,23 @@
bad_method?(node) do |safe_nav, method|
return if nil_methods.include?(method)
method_chain = method_chain(node)
location =
- Parser::Source::Range.new(node.loc.expression.source_buffer,
- safe_nav.loc.expression.end_pos,
- method_chain.loc.expression.end_pos)
+ Parser::Source::Range.new(node.source_range.source_buffer,
+ safe_nav.source_range.end_pos,
+ method_chain.source_range.end_pos)
add_offense(node, location: location)
end
end
private
def method_chain(node)
chain = node
while chain.send_type?
- chain = chain.parent if chain.parent &&
- %i[send csend].include?(chain.parent.type)
- break
+ chain = chain.parent if chain.parent&.call_type?
+ break # FIXME: Unconditional break. Why while "loop" then?
end
chain
end
end
end