Posts

Showing posts from September, 2007

Metrics for Rails

Everyone thinks they write good code -- it's just part of human nature. You can't do something every day and not secretly suspect that you're good at it. Self-delusion is a powerful thing so you need to use metrics to take a hard look at your code. On my current project, we've just added a daily metrics build (run every day at midnight by CruiseControl.rb ) that takes a look at our code in three ways: Code coverage with Rcov Cyclomatic complexity with Saikuro And um..., Flogging with Flog Rcov is a code coverage tool that can be used with Rails Rcov to add a bunch of rake tasks to your build so you can figure out which lines of code are run by your tests... and which are not. Saikuro computes cyclomatic complexity which "measures the number of linearly independent paths through a program's source code." Methods with more paths are harder to understand/debug/modify. And Flog is cyclomatic complexity with an attitude. It scores ruby methods with an &qu