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 Rails/HasManyOrHasOneDependent to correctly handle association methods with receiver #926

Merged

Conversation

fatkodima
Copy link
Contributor

Fixes #687.

PATTERN

def_node_matcher :association_with_options?, <<~PATTERN
(send nil? {:has_many :has_one} ... (hash $...))
(send _ {:has_many :has_one} ... (hash $...))
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned that accepting any receiver would increase false positives potential, but common user would refrain from creating has_many and has_one business methods in Rails. So Let's try this first.

@koic koic merged commit a7e8494 into rubocop:master Jan 27, 2023
@fatkodima fatkodima deleted the has_many_or_has_one_dependent-receiver branch January 27, 2023 10:07
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.

Rails/HasManyOrHasOneDependent false positive when has_one called on a class instance
2 participants