zombie_scout
zombie_scout copied to clipboard
Results are not displayed if the parser fails
zombie_scout
can fail after running for 15-20 minutes because the parser raises an error. This is undesirable because none of the results are displayed. It would be better to skip that file rather than crash.
Example code that failed to parse:
has_paper_trail on: :destroy
Error output (with Ruby and gem version information):
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.6-compliant syntax, but you are running 2.2.5.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
ERROR! Aborting. You may want to run with --continue.
/Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/racc/parser.rb:527:in `on_error': app/models/location.rb:13 :: parse error on value ":" (tCOLON) (Racc::ParseError)
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser_extras.rb:1163:in `on_error'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/racc/parser.rb:258:in `_racc_do_parse_c'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/racc/parser.rb:258:in `do_parse'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser_extras.rb:1075:in `block in process'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/timeout.rb:32:in `block in catch'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/2.2.0/timeout.rb:103:in `timeout'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser_extras.rb:1063:in `process'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser.rb:31:in `block in process'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser.rb:28:in `each'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/ruby_parser-3.9.0/lib/ruby_parser.rb:28:in `process'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/flog-4.6.1/lib/flog.rb:222:in `flog_ruby!'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/flog-4.6.1/lib/flog.rb:192:in `flog_ruby'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/flog-4.6.1/lib/flog.rb:180:in `block in flog'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/flog-4.6.1/lib/flog.rb:175:in `each'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/flog-4.6.1/lib/flog.rb:175:in `flog'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/flog_scorer.rb:19:in `raw_score'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/flog_scorer.rb:11:in `score'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/mission.rb:49:in `flog_score'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/mission.rb:23:in `block in scout'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/mission.rb:18:in `map'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/mission.rb:18:in `scout'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/lib/zombie_scout/app.rb:11:in `scout'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
from /Users/boakes/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/zombie_scout-0.0.6/bin/zombie_scout:5:in `<top (required)>'
from /Users/boakes/.rbenv/versions/2.2.5/bin/zombie_scout:23:in `load'
from /Users/boakes/.rbenv/versions/2.2.5/bin/zombie_scout:23:in `<main>'
Well that's no good.
Thanks for reporting, @benjaminoakes, I'll take a look. I'm thinking it'll be easiest/simplest to emit a warning. I'll try that & see how it goes.
The curious thing is that this is triggered by calculating the flog score. ZombieScout parses twice:
- on its own, with
parser
, to collect methods (and any method-calls, to avoid extra grepping) - through flog, with
ruby_parser
, to rank suspected zombies by severity
I'd guess that a bit of code wouldn't get past one, but not the other, but that's what your stack-trace implies. Still, I guess that's not so surprising.
What options should I specify to avoid the problem?