1

每天结束时,我都会在 RoR 环境中运行 metric_fu 来衡量代码质量。直到今天一切正常...

当我尝试运行 metric_fu 时,这是我从今天开始的结果。

$ bundle exec metric_fu -r
F, [2013-05-10T17:11:45.980014 #26798] FATAL -- : invalid byte sequence in UTF-8 (ArgumentError)
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/git_analyzer.rb:16:in `split'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/git_analyzer.rb:16:in `get_diff'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/source_control.rb:37:in `get_updated_files_from_log'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/source_control.rb:11:in `get_updated_files_change_info'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:250:in `parse_logs_for_updated_files'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:177:in `calculate_revision_data'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:165:in `block in calculate_revision_changes'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:160:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:160:in `calculate_revision_changes'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:59:in `analyze'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:44:in `report'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:32:in `report_churn'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:40:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:155:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:144:in `catch'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:144:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/factories.rb:18:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/factories.rb:25:in `Main'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:6:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/mf-churn:11:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/mf-churn:11:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/mf-churn:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/mf-churn:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/churn/churn.rb:10:in `analyze': undefined method `match' for nil:NilClass (NoMethodError)
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:129:in `block in generate_report'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:127:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:127:in `generate_report'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/reporting/report.rb:63:in `add'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:25:in `block in run_reports'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:23:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:23:in `run_reports'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:10:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/cli/helper.rb:11:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/cli/client.rb:18:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/metric_fu:9:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/metric_fu:19:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/metric_fu:19:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'

我在这里发现了一个类似的问题:https ://github.com/jscruggs/metric_fu/issues/61 。由于 GitHub 上的问题,我在项目的根目录中创建了一个名为“.metrics”的文件,内容如下:

MetricFu::Configuration.run do |config|   
  config.syntax_highlighting = false
end

不幸的是,这没有用。

最近几天除了代码没有更新,这就是为什么突然出现这个错误很奇怪。

这是我的 Ruby 版本:

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

提前致谢!

编辑

可以通过禁用流失来绕过该问题。您可以通过添加来禁用流失--no-churn,如下所示:

$ metric_fu -r --no-churn

编辑 2

由于我添加了--no-churn一次,Metric_fu 再次完全可操作。即使在下一个报告中激活了流失,同时分析了相同的代码。

Github 上的问题已创建:https ://github.com/metricfu/metric_fu/issues/70

4

2 回答 2

1

在 metric_fu 问题页面上输入一个问题 (那里有旧仓库的链接)。根据堆栈跟踪,这实际上可能是 Churn 中的一个问题(metric_fu 没有处理)。另请查看我的如何编写错误报告页面 ,我将与您一起解决那里的错误。

于 2013-05-11T03:51:11.730 回答
0

有趣的是,我还没有遇到它崩溃的项目或文件的任何其他细节?我可以尝试在流失中调试它,但没有太多事情要做。您可以直接提交 metric_fu 问题或 churn 问题。我关注这两个项目,所以我会尝试在任何一种情况下跟进。

于 2013-05-11T15:10:56.737 回答