How to configure metric_fu?

410 views
Skip to first unread message

Daria Mehra

unread,
Oct 28, 2013, 4:46:20 PM10/28/13
to metr...@googlegroups.com
Hi all, I'm new to ruby/rails and just started using metric_fu for our project. I found it difficult to figure out how to configure metric_fu. The links from github and several other sites that should take you to "configuration options" go to this page which appears obsolete and doesn't have config specifics: http://metric-fu.rubyforge.org/

My goal was to raise the threshold for Cane warnings about line length from 80 to 110, since we commonly have line overruns and don't want to see this warning. I found no documentation on how to do this and had to hunt through source code. I ended up with something that works:

.metrics file

MetricFu::Configuration.run do |config|
  config.configure_metric(:cane) do |cane|
    cane.line_length = 110
  end
end

The parameter name was not the same as what Cane expects on the command line (--style-measure) so it wasn't obvious. To help other newbies, it would be good to have a document pointing at the right places to look for configuration options. 

My remaining question now is this: to provide for Jenkins integration, it seems that I have to commit the .metrics file to my project repository. I prefer to avoid committing test-related files but in this case I'm not sure how to avoid that. It seems the file must exist in the project root directory for metric_fu to pick it up. Is there another way? Some environment variable setting perhaps? Or a command-line argument to metric_fu to tell it where to look for .metrics file? 

Thanks,
Daria.

Benjamin Fleischer

unread,
Oct 28, 2013, 10:22:16 PM10/28/13
to metr...@googlegroups.com


On Monday, October 28, 2013 3:46:20 PM UTC-5, Daria Mehra wrote:
Hi all, I'm new to ruby/rails and just started using metric_fu for our project. I found it difficult to figure out how to configure metric_fu. The links from github and several other sites that should take you to "configuration options" go to this page which appears obsolete and doesn't have config specifics: http://metric-fu.rubyforge.org/


Hi Daria,

I'd like to first offer you thanks for message here an apologies for failures in documentation.  MetricFu has been in a state of transition since I began maintaining it and I regret not to have kept the documentation very up to date.  One part of the documentation is that it has become out of date: the web site, the readme, and other docs.  I have an issue for the README https://github.com/metricfu/metric_fu/issues/114 and a wiki page to aid in user-contributed docs https://github.com/metricfu/metric_fu/wiki  I'd love it you could help out here, in any way.
 
My goal was to raise the threshold for Cane warnings about line length from 80 to 110, since we commonly have line overruns and don't want to see this warning.

I have an email in draft to address this, but basically, I think the current approach is incorrect, and metric options should map directly from metric_fu onto the metric it runs.
 
I found no documentation on how to do this and had to hunt through source code. I ended up with something that works:

Please add to the wiki, if you could, a link to the source file you looked at and your result, and version number it worked for.

My remaining question now is this: to provide for Jenkins integration,

I don't have a complete answer for this. I've collected a few links at the bottom of this page https://github.com/metricfu/metric_fu/wiki/Code-Tools but haven't organized them into usable docs, yet.  Right now, I would use the html publisher.  Robin might have other solutions.
 
it seems that I have to commit the .metrics file to my project repository. I prefer to avoid committing test-related files but in this case I'm not sure how to avoid that. It seems the file must exist in the project root directory for metric_fu to pick it up. Is there another way? Some environment variable setting perhaps? Or a command-line argument to metric_fu to tell it where to look for .metrics file? 


Not yet, but I definitely agree it's a need.  I think the command-line option and maybe home directory would be a good starting point. 

I'll try to get my email out tonight or tomorrow with more details about the direction and form the code base is taking

Again, thanks so much for writing.  I appreciate that you didn't just complain on twitter or write a blog post (not specifically a metric_f problem), but are actively contributing to the project by writing here.

-Benjamin

Daria Mehra

unread,
Oct 30, 2013, 5:48:36 PM10/30/13
to metr...@googlegroups.com
Hi Benjamin, as you requested I added notes on metric_fu configuration (changing thresholds) and integration with Jenkins to the wiki here: https://github.com/metricfu/metric_fu/wiki

Let me know how else I can help. 

By the way, I found that there was a Hudson plugin for MetricFu, which doesn't work with Jenkins (tried on 1.509) but I contacted the developer and there's a chance he'll update the plugin. 


-- daria.

Benjamin Fleischer

unread,
Oct 30, 2013, 6:00:08 PM10/30/13
to metr...@googlegroups.com

Wow, thanks Daria. I had intended on looking at updating the hudson plugin, but never thought to contact the developer. Clever ;)


On Wed, Oct 30, 2013 at 4:48 PM, Daria Mehra <daria...@gmail.com> wrote:
Hi Benjamin, as you requested I added notes on metric_fu configuration (changing thresholds) and integration with Jenkins to the wiki here: https://github.com/metricfu/metric_fu/wiki


Awesome!

-Benjamin 
Reply all
Reply to author
Forward
0 new messages