-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
First of all, thanks for an awesome project! 🏅
The current implementation will not complain about unused method arguments if the method raises a NotImplementedError
(it was implemented in this PR: #7739).
However, many recommend against raising this exception in your code:
- https://oleg0potapov.medium.com/ruby-notimplementederror-dont-use-it-dff1fd7228e5
- https://blog.airbrake.io/blog/ruby-exception-handling/notimplementederror
- http://chrisstump.online/2016/03/23/stop-abusing-notimplementederror/
These three posts all boil down to:
- Its actual meaning is different than the name implies – according to RubyDoc it should be raised when a feature is not implemented on the current platform, think of low-level things like calling fork or fsync.
- It's a descendant of
ScriptError
so a standard rescue block will not capture this, which may cause unexpected problems.
There is also ongoing discussion in this sibling repo to Rubocop:
Downside
It's somewhat weird to have def read_db(_name)
, where the real method name is name
.
Possible solution
- Add an option called
IgnoredExceptions
(array type), with the default value of['NotImplementedError']
.- For anyone who hasn't configured this cop, it's 100% backwards compatible.
- People who have set
IgnoreNotImplementedMethods
tofalse
would need to update their config to useIgnoredExceptions: []
intead.
- People who have set
- Could then deprecate the current option called
IgnoreNotImplementedMethods
and remove it in the next major.
- For anyone who hasn't configured this cop, it's 100% backwards compatible.
- Allow the yarddoc
@abstract
keyword to be used as another signal to disable this lint check on a method. - Remove the exception case for
NotImplementedError
(if you think the reasons for doing so makes sense). - Do nothing and consider this an edge case.
Docs for Lint/UnusedMethodArgument
Addendum
Also, I realize this is nuanced. So feel free to close this issue if you think it's irrelevant or that the current logic is "good enough".
zhisme, nertzy, leanne73, hmmoreira and hazi
Metadata
Metadata
Assignees
Labels
No labels