whitequark / parser

A Ruby parser.
Other
1.58k stars 198 forks source link

Supress warnings during parsing #1013

Open Earlopain opened 4 months ago

Earlopain commented 4 months ago

User input can contain arbitrary regexes. Something like Parser::CurrentRuby.parse("/[\177\01\1778]/") shows a warning:

character class has duplicated range: /[\x7f\x01\x7f8]/

I'm interested in getting the warning count in the RuboCop test suite down and since it has a few regex cops there are quite a few warnings of that kind as well. They are unactionable, RuboCop instead emulates these warnings by inspecting the ast parsing the regexp with the regexp_parser gem.


Also noticed the same for floats: Parser::CurrentRuby.parse("9.9999e999")

Float 9.9999e999 out of range

iliabylich commented 4 months ago

@koic Does it look good for you? I'm not sure if these warnings are a part of some implicit contract that other libraries might rely on. If not I believe we should merge it.

Earlopain commented 4 months ago

I've ignored these warnings in RuboCop itself so this is not strictly necessary. If you feel there is some risk associated here then feel free to close (though it would be nice not having to ignore these warnings)