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

[Fix #11704] Fix a false positive for Lint/UselessMethodDefinition #11705

Conversation

koic
Copy link
Member

@koic koic commented Mar 16, 2023

Fixes #11704.

This PR fixes a false positive for Lint/UselessMethodDefinition when method definition with non access modifier containing only super call.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

end
alias on_defs on_def

private

def modifiered_method_definition?(node)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with "method_definition_with_modifier?" here.

@@ -170,6 +214,14 @@ def method(x: 1)
RUBY
end

it 'does not register an offense when method definition with non access modifier containing only `super` call' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically speaking if it's not an access modifier we should probably call it should else - e.g. "generic method macro" or whatever. I'm not sure what's the best terminology here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the best terminology, but I think "generic method macro" is definitely a better name. Thank you for the suggestion! I've updated this PR.

…ition`

Fixes rubocop#11704.

This PR fixes a false positive for `Lint/UselessMethodDefinition`
when method definition with non access modifier containing only `super` call.
@koic koic force-pushed the fix_a_false_positive_for_lint_useless_method_definition branch from f7f54e4 to 82b0479 Compare March 18, 2023 09:15
@bbatsov bbatsov merged commit 32f4d0c into rubocop:master Mar 18, 2023
@koic koic deleted the fix_a_false_positive_for_lint_useless_method_definition branch March 18, 2023 21:27
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.

Lint/UselessMethodDefinition false positive on methods transformed by class method
2 participants