Skip to content

Commit

Permalink
Use Source::Range#join instead of Source::Range#with'
Browse files Browse the repository at this point in the history
Simple argument with `Source::Range#with` can be described using `Source::Range#join`.
  • Loading branch information
koic committed Apr 10, 2024
1 parent b0c508a commit f7d1a36
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/empty_conditional_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def branch_range(node)
node.source_range.with(end_pos: node.condition.source_range.end_pos)
elsif all_branches_body_missing?(node)
if_node = node.ancestors.detect(&:if?)
node.source_range.with(end_pos: if_node.loc.end.end_pos)
node.source_range.join(if_node.loc.end.end)
else
node.source_range
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/non_deterministic_require_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def correct_block_pass(corrector, node)
# @return [Parser::Source::Range]
#
def last_arg_range(node)
node.last_argument.source_range.with(begin_pos: node.arguments[-2].source_range.end_pos)
node.last_argument.source_range.join(node.arguments[-2].source_range.end)
end

def unsorted_dir_loop?(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/require_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def sibling_node(node)
end

def in_same_section?(node1, node2)
!node1.source_range.with(end_pos: node2.source_range.end_pos).source.include?("\n\n")
!node1.source_range.join(node2.source_range.end).source.include?("\n\n")
end
end
end
Expand Down

0 comments on commit f7d1a36

Please sign in to comment.