Reduce or remove errors and warnings when parsing invalid UTF-8
Closed this issue · 3 comments
When running against this bit of code:
RSpec.describe "invalid UTF8" do
let(:invalid_utf8) { "hello \255" }
it "is not the answer" do
expect(invalid_utf8).to_not eq(42)
end
end
I get these errors and warnings:
utf8_spec.rb:4:24: error: literal contains escape sequences incompatible with UTF-8
utf8_spec.rb:4: let(:invalid_utf8) { "hello \255" }
utf8_spec.rb:4: ^~~~~~~~~~~~
Warning! Skipping utf8_spec.rb due to parsing error!
utf8_spec.rb:4:24: error: literal contains escape sequences incompatible with UTF-8
utf8_spec.rb:4: let(:invalid_utf8) { "hello \255" }
utf8_spec.rb:4: ^~~~~~~~~~~~
Unable to resolve `let` on line 4.
@bquorning: Yeah, parser
doesn't support non-utf8 strings out of the box so right now I just skip any test files with invalid sequences. I'm pretty sure rubocop
has a patch for this or parser
has an option to turn it on or something, but I haven't had a chance to enable it yet. Hopefully I can get this stuff working sometime soon. If not, I do want to at least consolidate all the warnings so it just shows one message per file.
After reading whitequark/parser#323 I don’t think there’s any hope of fixing this issue…
Actually, I don't think so. The workaround ought to work just fine for RSpectre. I don't think there are any meaningful cases where I want to do operations on strings that have been parsed out with parser
so just letting "invalid" strings fly on through should be fine for us.