seattlerb / debride

Analyze code for potentially uncalled / dead methods, now with auto-removal.
https://www.zenspider.com/projects/debride.html
720 stars 19 forks source link

Should rescue RegexpError while parsing file. #34

Closed sizer closed 6 years ago

sizer commented 7 years ago

Because ruby_parser may throw RegexpError. - here is source.

If parsing file contains non escaped non ASCII char, debride fail while parsing file. debride's parsing log when failing is below.

I think we should skip parsing these file and finish Debride#run script. isn't is?

$ rake run D="./throw_regexperror_sample.rb"
WARNING: invalid multibyte character: /\【/ for "\\【" ""
WARNING: trying to recover with ENC_UTF8
WARNING: trying to recover with ENC_NONE
rake aborted!
RegexpError: /.../n has a non escaped non ASCII character in non ASCII-8BIT script: /\【/
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:110:in `process_rb'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:89:in `block in run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `each'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:71:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:39:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:43:in `block in <top (required)>'
RegexpError: invalid multibyte character: /\【/
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:110:in `process_rb'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:89:in `block in run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `each'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:71:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:39:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:43:in `block in <top (required)>'
RegexpError: invalid multibyte character: /\【/
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:110:in `process_rb'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:89:in `block in run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `each'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:76:in `run'
/Users/shinse/github/mrdshinse/debride/lib/debride.rb:71:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:39:in `run'
/Users/shinse/github/mrdshinse/debride/Rakefile:43:in `block in <top (required)>'
Tasks: TOP => run
(See full trace by running task with --trace)
zenspider commented 6 years ago

Done. thanks!