Using metric_fu to Make Your Rails Code Better

Posted in Conferences, Development, Frameworks on May 13, 2009



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.

 

Watch Video Watch Video on External Site Watch Video on External Site

Tags: Conferences, Ruby, Ruby On Rails, Frameworks, Metrics, Development, RailsConf 2009