-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add VarNode
class for lvar
, ivar
, cvar
and gvar
node types
#204
Conversation
lib/rubocop/ast/node/casgn_node.rb
Outdated
@@ -19,6 +19,7 @@ def namespace | |||
def name | |||
node_parts[1] | |||
end | |||
alias short_name name |
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.
CasgnNode
and Const
should have a symmetrical interface so that they can be compared (eg. in Lint/SelfAssignment
).
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.
Sounds good, but maybe the best would be to simply move all the implementation of Const
to a module and include this here too?
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.
@marcandre if you can take another look, I have extracted the methods from ConstNode
and included them in CasgnNode
as well. I called the mixin ConstantNode
but happy for a suggestion for a better name if you'd like.
This adds some new methods to CasgnNode
to mirror ConstNode
, so I've added tests for those as well.
@marcandre CI is failing on https://github.com/rubocop/rubocop/blob/345be1d50c6f44b8ae1a880f490d5faa1f368945/spec/rubocop/cop/metrics/utils/abc_size_calculator_spec.rb#L345-L360 because of Now Any ideas? |
731e408
to
6655719
Compare
Sorry, that's my code 😅 . |
Is there a way we can update
Do you mean something like: if defined?(RuboCop::AST::VarNode) ? RuboCop::AST::VarNode.new(...) : s(...)
I don't think we can do this because I think the issue is this I've had a little trouble tracing what's happening in that class though so I may be offbase. |
@dvandersluis Let me know if you're interested in reviving this PR, so we can drive it to the finish line. |
Sure, I'll take another look. |
09db497
to
beb2e66
Compare
beb2e66
to
f1b378a
Compare
So it looks like in the interim since this was last touched, the @marcandre @bbatsov if you're able please take a look 🙌 |
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.
Looks great, thank you 💪
Let me know if you need a release quickly for this, otherwise this will be released whenever the other upcoming issues & PR are resolved / soonish |
No rush on my end! Thanks @marcandre! |
Adds node classes for variables, to have symmetry with the assignment nodes. eg. a
lvasgn
andlvar
for the same variable should have the same value for the#name
method.