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 crash in dynamic module_function within a loop #116

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ripper-tags/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def on_method_add_arg(call, args)
method_name = args[1][1]
end

[procedure, klass, method_name, access, line]
[procedure, klass, method_name, access, line] if method_name
when "scope", "named_scope"
scope_name = args[1][0]
[:rails_def, :scope, scope_name, line] if scope_name
Expand Down
11 changes: 11 additions & 0 deletions test/test_ripper_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ def def() end
assert_equal('method', module_tags.find{ |t| t[:name] == 'def' }[:kind])
end

def test_dynamic_module_function
tags = extract(<<-RUBY)
module Airbrussh
ANSI_CODES.each do |name, code|
module_function(name)
end
end
RUBY
assert_equal ["Airbrussh"], tags.map { |t| t.fetch(:name) }
end

def test_extract_one_line_definition_access_by_symbol
%w(private public protected).each do |visibility|
tags = extract(<<-EOC)
Expand Down
Loading