Discourage usage of NotImplementedError
Proposal
Discourage usage of NotImplementedError
.
Rationale
- 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
orfsync
. - It's a descendant of
ScriptError
so arescue
block will not capture this. This might sound like a good thing but I believe we are using the mechanism in a way that it was not meant to be used.
Solutions
- Create a RuboCop rule that either:
- Asks
NoMethodError
with a message wheneverNotImplementedError
is raised - Create our own exception class for this and ask developers to raise that instead
- Perhaps create an issue on Ruby Issue Tracking System so maybe we'll get a new exception class in the language itself
Edited by Thiago Figueiró