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

Lint/MissingSuper: exclude method_missing and respond_to_missing? #9072

Merged
merged 2 commits into from Nov 21, 2020

Conversation

marcandre
Copy link
Contributor

Contrary to the other hooks, these have very valid cases to be completely taken over:

# accept everything:
def method_missing(method, *args)
  nil
end

# or delegate all
def method_missing(method, *args)
  delegate_to.send(method, *args)
end

While a class has a "right" to expect its other hooks to be called, these hooks aren't necessarily called the same way.

From standardrb/standard#195 (comment)

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 20, 2020

I'm fine with the proposed change, but I think it should be clearly explained in the cop's documentation why are those hooks treated differently.

@marcandre
Copy link
Contributor Author

I did my best while staying concise.

Contrary to the other hooks, these can be completely taken over:

```ruby
def method_missing(method, *args)
  nil
end

def method_missing(method, *args)
  delegate_to.send(method, *args)
end
```

While a class has a "right" to expect its other hooks to be called, these hooks aren't necessarily called the same way.
@bbatsov
Copy link
Collaborator

bbatsov commented Nov 21, 2020

Looks good! Thanks!

@marcandre marcandre deleted the nosuper branch November 21, 2020 09:35
patbl added a commit to academia-edu/linting-config that referenced this pull request Jan 12, 2021
Here are the relevant items from the changelog
(https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md):

1. In 0.89.0, "Style/MethodMissingSuper cop is removed in favor of new
Lint/MissingSuper cop."
2. rubocop/rubocop#9072 excludes
`method_missing` from the the Lint/MissingSuper cop.

The reason for (2) was that the "offenses" identified by the cop in
`method_missing` definitions were dominated by false positives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants