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

Cop idea: to_enum is the only usage of a method argument #9090

Open
paulslaby opened this issue Nov 24, 2020 · 0 comments
Open

Cop idea: to_enum is the only usage of a method argument #9090

paulslaby opened this issue Nov 24, 2020 · 0 comments

Comments

@paulslaby
Copy link

paulslaby commented Nov 24, 2020

Problem description

I just found a bug in my code which could have been found by a Cop.

    def method(args)
      return enum_for(:method, args) unless block_given?
      # never used args in this method
    end 

args argument is really used, but this idiom is very often used and it can tell me, that I used it only in enum_for

Describe the solution you'd like

I'd like to have a cop, which would tell me, that args is unused method argument.
It should complain, if receiver of enum_for is nil of self and the first argument is __method__

I don't know if UnusedMethodArgument, ToEnumArguments or a new Cop should cover it.

It is closely connected to #7753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants