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

New cop: Lint/UselessMethodDefinition #8472

Closed
fatkodima opened this issue Aug 6, 2020 · 2 comments · Fixed by #8552
Closed

New cop: Lint/UselessMethodDefinition #8472

fatkodima opened this issue Aug 6, 2020 · 2 comments · Fixed by #8552

Comments

@fatkodima
Copy link
Contributor

There are at least 2 cases:

  1. empty constructors - this may be just overriding parent's constructor, but this is bad anyway
  2. methods just calling super
@fatkodima fatkodima changed the title New cop: Lint/UselessMethod New cop: Lint/UselessMethodDefinition Aug 6, 2020
@ashmaroli
Copy link

I can think of one more use-case:

  • private methods not used in any of the other instance methods of the Class. Modules shouldn't be affected by the cop since the method may have significance when the module is mixed-in somewhere.

@biinari
Copy link
Contributor

biinari commented Aug 16, 2020

For private methods not used within the class, what about a child class that uses a private method of its parent?

class Parent
  private

  def foo
    'something'
  end
end

class Child < Parent
  def bar
    foo
  end
end

I'm not sure I would make a strong case for not detecting that but I do have some code like this. It may at least be worth considering as an unsafe autocorrection.

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

Successfully merging a pull request may close this issue.

4 participants