-
Notifications
You must be signed in to change notification settings - Fork 218
Adds support for attr_* method references #3706
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
base: main
Are you sure you want to change the base?
Adds support for attr_* method references #3706
Conversation
tests. Prob can use some cleanup
…r-method-references
How to use the Graphite Merge QueueAdd the label graphite-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
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.
Thanks for re-opening your PR and apologies for the slow response on our end! I just left two quick questions. I'll also re-run CI for you to make sure the tests look good.
if @target.is_a?(MethodTarget) && (name = node.name.to_s) == @target.method_name | ||
@references << Reference.new( | ||
name, | ||
node.message_loc, #: as !nil |
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.
Does type checking pass without this #: as !nil
?
def unescaped_argument_names(node) | ||
return [] if node.arguments.nil? | ||
|
||
node.arguments.arguments.select { |arg| arg.respond_to?(:unescaped) }.map(&:unescaped) |
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.
Can node.arguments.arguments
be nil?
Motivation
Shows references for methods defined with
attr_reader
,attr_writer
,attr_accessor
Re-opening stale PR #2848. Sorry this fell off my radar!
Closes #2668
Implementation
attr_reader
,attr_writer
,attr_accessor
are just methods, so on call node if we detect one of these methods, and one of the arguments match the target method name, add the reference.Additionally, I have ensured it works with empty and string arguments as well as added tests for these cases.
Automated Tests
Yes!
Manual Tests