summaryrefslogtreecommitdiff
path: root/rubocop/cop/prefer_class_methods_over_module.rb
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/cop/prefer_class_methods_over_module.rb')
-rw-r--r--rubocop/cop/prefer_class_methods_over_module.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/rubocop/cop/prefer_class_methods_over_module.rb b/rubocop/cop/prefer_class_methods_over_module.rb
index 496d2ed249f..ed10229b69a 100644
--- a/rubocop/cop/prefer_class_methods_over_module.rb
+++ b/rubocop/cop/prefer_class_methods_over_module.rb
@@ -48,12 +48,15 @@ module RuboCop
private
def extends_activesupport_concern?(node)
- container_module(node.parent)&.descendants.any? do |descendant|
+ container_module = container_module_of(node.parent)
+ return false unless container_module
+
+ container_module.descendants.any? do |descendant|
extend_activesupport_concern?(descendant)
end
end
- def container_module(node)
+ def container_module_of(node)
node = node.parent until node.type == :module
node