HEREDOC parse error & warning on SQL string with no substitution
ERROR IS:
product_ingredients_controller.rb:8 :: parse error on value "<<" (tLSHFT)
Could not parse product_ingredients_controller.rb
CODE (notice the squiggly heredoc: <<~ not <<-
def recipeslist
query =<<~SQL.gsub(/[\s\t]*\n/, ' ').strip
select
i.*,
pi.*,
p.*,
p.id as "product_id",
p.brand_id,
b.name as "brandname"
from product_ingredients pi
join ingredients i on pi.ingredient_id = i.id
join products p on pi.product_id = p.id
join brands b on b.id = p.brand_id
where pi.client_id = #{@_user_client_id}
and i.client_id = #{@_user_client_id}
and p.client_id = #{@_user_client_id}
order by
b.name,
p.description,
pi.product_id,
i.name
SQL
@report = Ingredient.find_by_sql(query)
As I mentioned in #1025, <<~ is not supported yet. It's not possible that Brakeman is generating a warning about this code. It can't be warning about code in a file that can't be parsed.
It would be helpful to see the SQL injection warning. I would suggest using the -f plain or -f html reports so the file name is reported.
http://www.zenspider.com/releases/2017/07/ruby_parser-version-3-10-0-has-been-released.html
Time to bump ruby_parser to pick up squiggly heredocs support :)
The 3.7.0 release of Brakeman included those changes already if you are using the brakeman gem.
Still not sure where the "warning on SQL string with no substitution" part comes from or what you mean by it. There is substitution (@_user_client_id) and Brakeman probably should warn on it.