Open zoras opened 1 year ago
Thanks @zoras for reporting.
Is it correct that you succeed in non-parallel mode, but fail in parallel mode? There seems to be a problem parsing a particular Slim template, so could you please tell me the contents of that template so I can find the cause?
I think this is probably the same issue as the one you posted just before:
Is it correct that you succeed in non-parallel mode, but fail in parallel mode? No, when I run in non-parallel mode I get errors but it fails without error in parallel mode.
This is slim file with error
~/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/slimi-0.7.4/lib/slimi/parser.rb:571:in `syntax_error!': MalformedIndentationError at _file.slim:23:9 (Slimi::Errors::MalformedIndentationError)
i.fa-circle
Okay, so it seems there are two problems.
One is that when an exception occurs in the parser inside RuboCop, the exception is not reported properly when running in parallel mode. This is a problem that should be improved on the RuboCop side.
The other is either a problem with the slimi parser or with the way the slim template is written. I see that the exception is that there is a problem with indentation.
For example, if you have written a Slim template with wrong indentation like the following, you will get an exception.
a
b
i.fa-circle
$ cat example.slim | slimi parse
/home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:571:in `syntax_error!': MalformedIndentationError at (__TEMPLATE__):3:3 (Slimi::Errors::MalformedIndentationError)
i.fa-circle
^
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:105:in `parse_indent'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:62:in `parse_block'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:53:in `call'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/cli.rb:25:in `parse'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/exe/slimi:7:in `<top (required)>'
from /home/r7kamura/.rbenv/versions/3.1.3/bin/slimi:25:in `load'
from /home/r7kamura/.rbenv/versions/3.1.3/bin/slimi:25:in `<main>
What is the code before and after the line where the exception is reported?
What is the code before and after the line where the exception is reported?
= link_to url_for([:a, :b, file]), class: 'class', method: :post,
title: 'Awesome Title' do
i.fa-circle
Hmmm...thanks, I'm pretty close to identifying the cause 👍
I thought this whitespace in the last line was incorrect for Slim syntax, but I see that it is successfully parsed in slimrb
and fails in slimi:
$ cat example.slim | slimrb --compile
_buf = ''.dup; _slim_controls1 = link_to url_for([:a, :b, file]), class: 'class', method: :post,
title: 'Awesome Title' do; _slim_controls2 = ''.dup;
; _slim_controls2 << ("<i class=\"fa-circle\"></i>".freeze);
;
; _slim_controls2; end; _buf << ((::Temple::Utils.escape_html((_slim_controls1))).to_s); _buf
$ cat example.slim | slimi compile
/home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:571:in `syntax_error!': MalformedIndentationError at (__TEMPLATE__):3:9 (Slimi::Errors::MalformedIndentationError)
i.fa-circle
^
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:105:in `parse_indent'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:62:in `parse_block'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/parser.rb:53:in `call'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `block in call'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `each'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `inject'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `call'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/lib/slimi/cli.rb:11:in `compile'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
from /home/r7kamura/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/slimi-0.7.4/exe/slimi:7:in `<top (required)>'
from /home/r7kamura/.rbenv/versions/3.1.3/bin/slimi:25:in `load'
from /home/r7kamura/.rbenv/versions/3.1.3/bin/slimi:25:in `<main>'
It seems to me that this is an Issue that should be taken up by slimi, the template parser, so I will transfer this Issue to that repository.
Adding a conditional branch here that does not raise an exception if it is a blank line (i.e., the next character is a newline) might resolve this issue: