Skip to content

Commit 0661da3

Browse files
authored
[ERB] Enforce space between do and params for do block (#21)
* bug fixes * Reworked ERB transformation to perform a series of appending calls to a buffer' * rename buffers to prefix with joern__ to distinguish variables * Remove prefix and postfix tag calls. Add call to original function before lambda lowering * code cleanup * add unit test showing lowered ERB code * Update do block regex
1 parent 390c508 commit 0661da3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/ruby_ast_gen/erb_to_ruby_transformer.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ def visit(node)
9797
end
9898
end
9999

100-
101100
def is_control_struct_start(line)
102-
line.start_with?('if', 'unless', 'elsif', 'else', /@?\w+\.each\sdo/)
101+
line.start_with?('if', 'unless', 'elsif', 'else', /@?.+\.(each|each_with_index)\sdo/)
103102
end
104103

105104
def lambda_incrementor()
@@ -113,7 +112,7 @@ def current_lambda()
113112
end
114113

115114
def lower_do_block(code)
116-
if (code_match = code.match(/do\s*(?:\|([^|]*)\|)?/))
115+
if (code_match = code.match(/do\s+(?:\|([^|]*)\|)?/))
117116
@current_lambda_vars = code_match[1]
118117
before_do, _ = code.split(/\bdo\b/)
119118
unless before_do.nil?

0 commit comments

Comments
 (0)