Skip to content

Commit

Permalink
[Fix #184] Fix Node#parent_module_name for sclass nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvandersluis authored and marcandre committed Aug 10, 2021
1 parent f7fcd3e commit 24a1a0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/fix_fix_184_fix_nodeparent_module_name_for.md
@@ -0,0 +1 @@
* [#197](https://github.com/rubocop-hq/rubocop-ast/pull/197): [Fix #184] Fix `Node#parent_module_name` for `sclass` nodes. ([@dvandersluis][])
6 changes: 5 additions & 1 deletion lib/rubocop/ast/node.rb
Expand Up @@ -317,7 +317,11 @@ def parent_module_name
# returns nil if answer cannot be determined
ancestors = each_ancestor(:class, :module, :sclass, :casgn, :block)
result = ancestors.map do |ancestor|
parent_module_name_part(ancestor) { |full_name| return full_name }
parent_module_name_part(ancestor) do |full_name|
return nil unless full_name

full_name
end
end.compact.reverse.join('::')
result.empty? ? 'Object' : result
end
Expand Down

0 comments on commit 24a1a0d

Please sign in to comment.