Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#Fix 334] Make body consistent for RescueNode, EnsureNode and KeywordBeginNode #336

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Nov 11, 2024

Renames EnsureNode#body to #branch, and adds a new #body method in line with RescueNode and KeywordBeginNode to return the body of code being executed before exception handling. For all three node types, body will now return a single node (which may be a begin/kwbegin node containing multiple nodes).

begin
  foo       <--- body
  bar       <--- body
rescue 
  baz
ensure
  quux
end

This is a breaking change, as existing code that calls EnsureNode#body will need to be updated.

Fixes #334.

@dvandersluis
Copy link
Member Author

I'm not sure when the plan for the next major version is, but getting this kicked off now so it's ready for whenever that'll be.

# Returns an the ensure branch in the exception handling statement.
#
# @return [Node, nil] the body of the ensure branch.
def branch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used branch for the method to get the ensure branch body, similiar to how we have branches for RescueNode.

@dvandersluis
Copy link
Member Author

I've gone through every rubocop-* repo in the @rubocop org. As far as I can see, only rubocop/rubocop and rubocop/rubocop-minitest are affected by this change. For tracking purposes, here are the PRs to update EnsureNode.body in those repos:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency between RescueNode and EnsureNode
1 participant