# Some help with metric-fu

**URL:** <https://www.ruby-forum.com/t/some-help-with-metric-fu/172449>\
**Category:** Rails\
**Created:** [July 21, 2009, 6:15pm UTC](https://www.ruby-forum.com/t/some-help-with-metric-fu/172449 "2009-07-21T18:15:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m4lloc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/87869e/32.png) [@m4lloc](https://www.ruby-forum.com/u/m4lloc)\
**Post date:** [July 21, 2009, 6:15pm UTC](https://www.ruby-forum.com/t/some-help-with-metric-fu/172449/1 "2009-07-21T18:15:48Z")

</div>

I’m apologize for my English, before.

I’m doing a post graduation thesis about BDD, an my initial idea is to  
compare a ruby program built by TDD and after by BDD. In these cases,  
the both projects have identical code, excepts the tests that were made  
by Test::Unit and Rspec respectively. So I’m using some code metrics  
like rcov, flay, flog and etc. for compare the generated tests.

I made the same for a rails project. I built a blog with three models  
(user, post and comment) using TDD approach using Test::Unit. After I  
did the same project using the BDD approach for build the same code but  
using rspec instead Test::Unit framework. In both projects the total  
number of tests are the same and the code generated are identical. So I  
tried to use metric-fu for compare these rails projects and the results  
left me frustrated.

The flog and roodi’s metrics showing noting!  
I need to measure files user.rb, post.rb, comment.rb  
in app/models and user\_test.rb, post\_test.rb, comment\_test.rb in  
test/unit.

My metric-fu.rake is:

begin  
require ‘metric\_fu’  
MetricFu::Configuration.run do |config|  
#define which metrics you want to use  
config.metrics = [:churn, :saikuro, :stats, :flog, :flay,  
:reek, :roodi, :rcov]  
config.graphs = []  
config.flay = { :dirs\_to\_flay =\> [‘app/models’, ‘test/unit’,  
‘lib’] }  
config.flog = { :dirs\_to\_flog =\> [‘app/models’, ‘test/unit’,  
‘lib’] }  
config.reek = { :dirs\_to\_reek =\> [‘app/models’, ‘test/unit’,  
‘lib’] }  
config.roodi = { :dirs\_to\_roodi =\> [‘app/models’,‘test/unit’,  
‘lib’] }  
config.saikuro = { :output\_directory =\>  
‘scratch\_directory/saikuro’,  
:input\_directory =\> [‘app/models’,  
‘test/unit’, ‘lib’],  
:cyclo =\> “”,  
:filter\_cyclo =\> “0”,  
:warn\_cyclo =\> “5”,  
:error\_cyclo =\> “7”,  
:formater =\> “text”}  
config.churn = { :start\_date =\> “1 year ago”,  
:minimum\_churn\_count =\> 10}  
config.rcov[:rcov\_opts] \<\< “-Itest”  
end  
rescue LoadError  
end

and for rails rspec project

begin  
require ‘metric\_fu’  
MetricFu::Configuration.run do |config|  
#define which metrics you want to use  
config.metrics = [:churn, :saikuro, :stats, :flog, :flay,  
:reek, :roodi, :rcov]  
config.graphs = []  
config.flay = { :dirs\_to\_flay =\> [‘app/models’,  
‘spec/models’, ‘lib’] }  
config.flog = { :dirs\_to\_flog =\> [‘app/models’,  
‘spec/models’, ‘lib’] }  
config.reek = { :dirs\_to\_reek =\> [‘app/models’,  
‘spec/models’, ‘lib’] }  
config.roodi = { :dirs\_to\_roodi =\>  
[‘app/models’,‘spec/models’, ‘lib’] }  
config.saikuro = { :output\_directory =\>  
‘scratch\_directory/saikuro’,  
:input\_directory =\> [‘app/models’,  
‘spec/models’, ‘lib’],  
:cyclo =\> “”,  
:filter\_cyclo =\> “0”,  
:warn\_cyclo =\> “5”,  
:error\_cyclo =\> “7”,  
:formater =\> “text”}  
config.churn = { :start\_date =\> “1 year ago”,  
:minimum\_churn\_count =\> 10}  
config.rcov[:rcov\_opts] \<\< “-Itest” # doens’t work too.  
end  
rescue LoadError  
end

I need to improve this rake file for show more information (and to  
include flog and roodi measures).

For me rcov doesn’t work with this default configuration:

config.rcov = { :test\_files =\> [‘test/**/\*\_test.rb’,  
'spec/**/\*\_spec.rb’],  
:rcov\_opts =\> ["–sort coverage",  
“–no-html”,  
“–text-coverage”,  
“–no-color”,  
“–profile”,  
“–rails”,  
“–exclude  
/gems/,/Library/,spec”]}  
Why?

And when I execute rake metrics :all these errors happen:

(in /home/bruno/workRails/blog\_spec)

- master

/usr/local/lib/ruby/gems/1.8/gems/flog-2.1.2/bin/flog:11: undefined  
method `flog\_files’ for #Flog:0xb7903708 (NoMethodError)

from /usr/local/bin/flog:19:in `load’

from /usr/local/bin/flog:19

No file to analyze was found. All the files loaded by rcov matched one  
of the

following expressions, and were thus ignored:

[/\A/usr/local/lib/,

/\btc\_[^.]\*.rb/,

/\_test.rb\z/,  
â€¦ and blablabla

Can anyone help me with these questions?

Thank’s so much, Bruno.
