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

Allow unused variables when a class method only raises a NotImplementedError #7739

Closed
deiden26 opened this issue Feb 21, 2020 · 0 comments · Fixed by #7747
Closed

Allow unused variables when a class method only raises a NotImplementedError #7739

deiden26 opened this issue Feb 21, 2020 · 0 comments · Fixed by #7747

Comments

@deiden26
Copy link

Is your feature request related to a problem? Please describe.

While the style guide prefers duck typing over inheritance, many developers prefer inheritance for the sake of communicating structure to other developers. If a method both has arguments and raises a NotImplementedError – a common pattern for defining method signatures – the Lint/UnusedMethodArgument warning is triggered.

Describe the solution you'd like

I would like functions with arguments that only contain raise NotImplementedError to be ignored by Lint/UnusedMethodArgument. Ideally, there would be a setting (maybe IgnoreNotImplementedMethods) that is true by default.

This should not trigger any warnings

class Example
  def process_thing(thing)
    raise NotImplementedError
  end
end

Describe alternatives you've considered

Currently you can use the following work arounds

Leave a method empty, because IgnoreEmptyMethods is true by default

This is insufficient, because in many cases calling a method should immediately fail if it hasn't been implemented by a child class. Otherwise, bugs can appear far deeper in the execution path.

Prefix the variables with an underscore

This is insufficient, as it communicates that the prefixed argument(s) are optional. They may not be.

Don't include arguments in the signature

This is insufficient, as it fails to communicate the arguments child classes should expect for a method.

@deiden26 deiden26 changed the title Allow unused variables when funciton only raises a NotImplementedError Allow unused variables when a class method only raises a NotImplementedError Feb 21, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Mar 22, 2020
bbatsov pushed a commit that referenced this issue Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants