From 4631bb2095050e56a6d06b7e8a57213115a2cc21 Mon Sep 17 00:00:00 2001 From: goose Date: Fri, 5 Jan 2024 15:58:32 +0700 Subject: [PATCH] [#494] Better function names --- custom_cops/required_inverse_of_relations.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_cops/required_inverse_of_relations.rb b/custom_cops/required_inverse_of_relations.rb index 9c575c50..9ad37824 100644 --- a/custom_cops/required_inverse_of_relations.rb +++ b/custom_cops/required_inverse_of_relations.rb @@ -8,18 +8,18 @@ class RequiredInverseOfRelations < RuboCop::Cop::Base RESTRICT_ON_SEND = %i[has_many belongs_to].freeze ASSOCIATION_METHODS = RESTRICT_ON_SEND.to_set - def_node_matcher :missing_inverse_of_no_arguments?, <<~PATTERN + def_node_matcher :association_expression_no_arguments?, <<~PATTERN (send nil? ASSOCIATION_METHODS (sym _)) PATTERN - def_node_matcher :missing_inverse_of_with_arguments?, <<~PATTERN + def_node_matcher :association_expression_with_arguments?, <<~PATTERN (send nil? ASSOCIATION_METHODS (sym _) (hash $...)) PATTERN def on_send(node) - return add_offense(node) if missing_inverse_of_no_arguments?(node) + return add_offense(node) if association_expression_no_arguments?(node) - return unless (hash_pairs = missing_inverse_of_with_arguments?(node)) + return unless (hash_pairs = association_expression_with_arguments?(node)) add_offense(node) unless contain_inverse_of?(hash_pairs) end