Using metric_fu to Make Your Rails Code Better

Location: Pavilion 9 - 10 Level:
Average rating: ****.
(4.31, 35 ratings)

You’ve got yourself a Rails project and a bunch of developers. Some of those devs are awesome and others are… not so awesome. How can you make sure that your beautiful code doesn’t degrade over time as more people join the project and deadlines loom? Or maybe you’re on a project that has lots of “bad parts of town” and you want to make it better – how will you know if you’re really making a difference? And where to start? Well, the growing field of code metrics is here to help. There are tools to measure test coverage, code complexity, churn (code that needs to change whenever anything changes), bad practices, duplication, and code smells. And all of these various open source projects have been mashed together in metric_fu – a Ruby gem that makes measuring the quality of your code easy (or at least easier).

During this talk I’ll be covering the various projects used by metric_fu to produce its reports:

  • Rcov – Measures test coverage
  • Flog – Measures code complexity
  • Saikuro – Measures cyclomatic complexity
  • Flay – Finds duplication (both copy/paste and structural)
  • Reek – Spots code smells
  • Roodi – Finds lots of general problems
  • Churn – Identifies files that change too often

I’ll discuss what the reports mean, how to fix the problems they uncover (with code examples), and setting up a Cruise Control build to generate these reports automatically once a day so you can have historical data.

Jake Scruggs

Backstop Solutions

{"High School Physics Teacher" => 7.years, “Object Mentor Apprentice” => 3.months, “ThoughtWorker” => 4.years, “Obtivian” => 1.year}

Comments on this page are now closed.


Russ Schissler
05/06/2009 4:30am PDT

and thanks for YAThing to start doing in all my spare time.

Russ Schissler
05/06/2009 4:29am PDT

... and thanks for YAthing to start doing.

Russ Schissler
05/06/2009 4:29am PDT

Good session, well presented with complete info, slides, some good developer style combined with physics teacher podium confidence and fun. Hope the slides show up on the site.

News and Coverage
co-presented by Ruby Central, Inc. O'Reilly
  • Engine Yard
  • Heroku
  • Sun Microsystems
  • Blue Box Group
  • New Relic

Sponsorship Opportunities

For information on exhibition and sponsorship opportunities at RailsConf, contact Yvonne Romaine at

Download the RailsConf Sponsor/Exhibitor Prospectus

Media Partner Opportunities

Download the Media & Promotional Partner Brochure (PDF) for information on trade opportunities with O'Reilly conferences or contact mediapartners@

Program Ideas

Post your suggestions for speakers, topics, and activities on the RailsConf wiki or send an email to

Press and Media

For media-related inquiries, contact Maureen Jennings at

Contact Us

View a complete list of RailsConf 2009 contacts.