Trying to exclude some metrics from metric_fu report

213 views
Skip to first unread message

Michel Sánchez Montells

unread,
Sep 25, 2013, 4:20:58 PM9/25/13
to metr...@googlegroups.com

I am using metric_fu 4.4.1, and want to exclude reek, flay, flog reports from metric_fu's report

my .metrics file says:

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

my metric_fu.rake says:

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

when i run: bundle exec rake metrics:all get the following error

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)

Benjamin Fleischer

unread,
Sep 25, 2013, 4:47:02 PM9/25/13
to metr...@googlegroups.com
Hi Michel-

It appears we would do well to add some deprecated method handlers.  I had this happen to me earlier today due to an older .metrics file.

Due to changes in how metrics are being loaded, your .metrics file should instead read
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

Though I admit we could improve the interface here. That should be done by 5.0.  See the sample .metrics file in the repo https://github.com/metricfu/metric_fu/blob/master/.metrics

The second issue is that metric_fu now runs from the command line and no longer requires rake or bundler integration.  (There's actually some failures via rake that don't occur on the command line)

So, you could run metric_fu as

metric_fu --no-reek --no-flog --no-flay

Hope that helps!

-Benjamin

Michel Sánchez Montells

unread,
Sep 26, 2013, 10:07:55 AM9/26/13
to metr...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages