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

InternalAffairs/NodeMatcherDirective should support class methods #12665

Closed
bquorning opened this issue Jan 31, 2024 · 1 comment · Fixed by #12753
Closed

InternalAffairs/NodeMatcherDirective should support class methods #12665

bquorning opened this issue Jan 31, 2024 · 1 comment · Fixed by #12753

Comments

@bquorning
Copy link
Contributor

In rubocop/rubocop-rspec#1793, we are using def_node_matcher to define class methods. On this bit of code

# @!method self.foo(node)
def_node_matcher 'self.foo', '(send ...)'

I get the following result:

[...] C: [Correctable] InternalAffairs/NodeMatcherDirective: @!method YARD directive has invalid method name, use self.foo instead of self.
def_node_matcher 'self.foo', '(send ...)'

Note the “self.foo instead of self.” part.

Running rubocop --autocorrect changes the YARD comment into this monstrosity:

# @!method self.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo(node)

Actually, I think the correct YARD comment for a class method might be two lines:

# @!method foo(node)
# @!scope class

RuboCop version

$ bundle exec rubocop -V
1.60.2 (using Parser 3.3.0.5, rubocop-ast 1.30.0, running on ruby 2.7.8) [arm64-darwin22]
  - rubocop-performance 1.20.2
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.26.1
@bquorning
Copy link
Contributor Author

@dvandersluis Based on you authoring #9506, this issue may be of interest to you.

Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 6, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 6, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 7, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 7, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 7, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 7, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 7, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue Mar 8, 2024
koic added a commit that referenced this issue Mar 8, 2024
[Fix #12665] Fix infinite loop for `InternalAffairs/NodeMatcherDirective` with class methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant