Skip to content

About the NotImplementedError exception for Lint/UnusedMethodArgument #11393

@sandstrom

Description

@sandstrom

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:

These three posts all boil down to:

  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 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 to false would need to update their config to use IgnoredExceptions: [] intead.
    • Could then deprecate the current option called IgnoreNotImplementedMethods and remove it in the next major.
  • 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

image

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy