Skip to content

Discourage usage of NotImplementedError

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Proposal

Discourage usage of NotImplementedError.

Rationale

  1. 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.
  2. It's a descendant of ScriptError so a rescue 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

  1. Create a RuboCop rule that either:
  • Asks NoMethodError with a message whenever NotImplementedError is raised
  • Create our own exception class for this and ask developers to raise that instead
  1. Perhaps create an issue on Ruby Issue Tracking System so maybe we'll get a new exception class in the language itself

/cc @gitlab-org/maintainers/rails-backend

Edited by 🤖 GitLab Bot 🤖