如何从metric_fu中排除某些指标

时间:2013-09-25 17:59:22

标签: ruby-on-rails metrics metric-fu

我正在使用metric_fu 4.4.1

我的.metrics文件说:

MetricFu::Configuration.run do |config|  
 config.metrics -= [:reek]  
 config.metrics -= [:flay]  
 config.metrics -= [:flog]
end

my metric_fu.rake说:

begin
  require 'metric_fu'
rescue LoadError
  puts 'Could not load metric_fu'
end 

当我运行时:捆绑exec rake指标:全部 得到以下错误

rake aborted!
undefined method `metrics' for #<MetricFu::Configuration:0xa3d4f14>
/home/montells/Projects/beesor/.metrics:2:in `block in <top (required)>'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/metric_fu-4.4.1/lib/metric_fu/configuration.rb:102:in `run'
/home/montells/Projects/beesor/.metrics:1:in `<top (required)>'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/metric_fu-4.4.1/lib/metric_fu/run.rb:32:in `load_user_configuration'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/metric_fu-4.4.1/lib/metric_fu/run.rb:6:in `initialize'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/metric_fu-4.4.1/lib/metric_fu/tasks/metric_fu.rake:5:in `new'
/home/montells/.rvm/gems/ruby-1.9.3-p392/gems/metric_fu-4.4.1/lib/metric_fu/tasks/metric_fu.rake:5:in `block (2 levels) in <top (required)>'
Tasks: TOP => metrics:all
(See full trace by running task with --trace)

1 个答案:

答案 0 :(得分:2)

我通过谷歌小组收到了这个问题的答案。 click here

MetricFu::Configuration.run do |config|
  config.configure_metrics.each do |metric|
    if [:reek, :flay, :flog].include?(metric.name)
      metric.enabled = false
    else
      metric.enabled = true
    end
  end
end

并向Benjamin Fleischer定价