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

Mark RuboCop::AST::EnsureNode as being in a void context. #309

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/change_mark_ensure_as_void_context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#309](https://github.com/rubocop/rubocop-ast/pull/309): Mark `RuboCop::AST::EnsureNode` as being in a void context. ([@earlopain][])
8 changes: 8 additions & 0 deletions lib/rubocop/ast/node/ensure_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class EnsureNode < Node
def body
node_parts[1]
end

# Checks whether this node body is a void context.
# Always `true` for `ensure`.
#
# @return [true] whether the `ensure` node body is a void context
def void_context?
true
end
end
end
end
6 changes: 6 additions & 0 deletions spec/rubocop/ast/ensure_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@

it { expect(ensure_node.body).to be_sym_type }
end

describe '#void_context?' do
let(:source) { 'begin; beginbody; ensure; ensurebody; end' }

it { expect(ensure_node).to be_void_context }
end
end