Metrical metric_fu ruby1.9.2 Rails3.0 undefined method `length' for nil:NilClass

419 Views Asked by At

I am trying to run metric_fu with my rails 3.0 application. I have checked metrical gem to avoid dependencies problems and make it easier to setup metric_fu.

I could let it work but only having one exception

/home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:239:in `block in scan_delimited_region': undefined method `length' for nil:NilClass (NoMethodError)
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:231:in `loop'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:231:in `scan_delimited_region'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb:143:in `step'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/common.rb:77:in `tokenize'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/syntax-1.0.0/lib/syntax/convertors/html.rb:16:in `convert'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:59:in `block (2 levels) in write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `each'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `each_with_index'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:46:in `block in write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:40:in `each_pair'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:40:in `write_file_data'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb:34:in `write'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metric_fu-2.1.1/lib/base/report.rb:48:in `save_templatized_report'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metrical-0.0.7/lib/metrical.rb:54:in `run_metric_fu'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metrical-0.0.7/lib/metrical.rb:18:in `run'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/gems/metrical-0.0.7/bin/metrical:4:in `<top (required)>'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/bin/metrical:19:in `load'
from /home/mahmoud/.rvm/gems/ruby-1.9.2-p180@metrics/bin/metrical:19:in `<main>'

I tried to edit this file gems/syntax-1.0.0/lib/syntax/lang/ruby.rb line#239

start_group inner_group, text if text.length > 0

and edited it to be

start_group inner_group, text if !text.blank?

It worked without exception this time and I could generate the metric_fu report but with two problems:

  1. The mertrical task didn't finish its work. It seems it is got in an infinite loop.
  2. Some reports like reek, roodi and rails best practices could display results successfully, but don't display charts; they display "NO Data" in place of charts

I am not sure if my ruby code update harms it or something else?

0

There are 0 best solutions below