Search code examples
rubyrubocoprubocop-nodepattern

Rubocop custom cop nodepattern class method regardless class/modules


I would like to catch all the bar class methods regardless its class/module.

I can catch Foo.bar with (send (const nil? :Foo) :bar) but i would like to catch Woohoo::Foo.bar or even Woohoo::Foo.bar(some_attr: some_value).

I basically want to say .bar method is deprecated use some_new_method instead.

Is there a way to do it?

Thanks to you all!


Solution

  • Yes, instead of forcing the constant's scope to be nil?, you can accept any scope with

    (send (const _ :Foo) :bar)