-
-
Notifications
You must be signed in to change notification settings - Fork 55
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 RuboCop::AST::DefNode#void_context?
to handle class methods called initialize
#310
Conversation
…led `initialize`
@@ -13,7 +13,7 @@ class DefNode < Node | |||
# | |||
# @return [Boolean] whether the `def` node body is a void context | |||
def void_context? | |||
method?(:initialize) || assignment_method? | |||
(def_type? && method?(:initialize)) || assignment_method? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually this makes sense to me, though I wonder if would be better to instead introduce a DefsNode
instead which then overrides this method. Not sure if worth the effort, lets wait on other input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thought DefsNode
was already defined going into this.
I'd rather not make drastic changes in this PR. This is a pre-existing pattern (used in BlockNode
for example):
if numblock_type? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. Yeah, probably fine then. I did a quick search around but didn't find other nodes that did it like this but clearly I didn't search good enough.
Sorry for the delay, I missed the notification. Thanks for the PR 👍 My cell phone just died on me, so I can't release right now, but will in a few days. |
@marcandre If you’d like, I can go ahead and handle the release. Shall I handle the release? |
Sure, that'd be great, thanks @koic ❤️ |
RuboCop AST 1.32.3 has been released. I hope your cell phone gets fixed soon :-) |
Currently,
DefNode#void_context?
incorrectly returnstrue
for class methods calledinitialize
. This PR fixes this.