度量metric_fu ruby​​1.9.2 Rails3.0未定义方法`length'对于 nil:NilClass

发布于 2024-12-13 04:23:37 字数 3009 浏览 1 评论 0原文

我正在尝试使用我的 Rails 3.0 应用程序运行 metric_fu 。 我已经检查了 metrical gem 以避免依赖问题并使设置 metric_fu 变得更容易。

我可以让它工作,但只有一个例外

/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>'

我尝试编辑此文件 gems/syntax-1.0.0/lib/syntax/lang/ruby.rb line#239

start_group inner_group, text if text.length > 0

并将其编辑为

start_group inner_group, text if !text.blank?

这次它毫无例外地工作,我可以生成 metric_fu 报告,但存在两个问题:

  1. metric 任务未完成其工作。看起来它陷入了无限循环。
  2. 一些报告(例如 reek、roodi 和 Rails 最佳实践)可以成功显示结果,但不显示图表;他们显示“无数据”而不是图表

我不确定我的 ruby​​ 代码更新是否会损害它或其他什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文