Watch for Turbulence

Mike Burns

How important is the refactoring you’re working on? Michael Feathers has a metric you should consider when deciding: plot the complexity against the churn.

Chad Fowler’s turbulence gem does just that.

The “complexity” is some arbitrary number of how tricky the code is to read; this can range from the amount of indentation to the amount of metaprogramming, and everything in between. This is computed using flog.

“Churn” simply refers to how often a file changes; a file that’s changed a bunch has high churn. Highly-churned files should be easy to modify, since people do it a ton. This is computing using git.

Using it is simple: drop this in your Gemfile:

group :development do
  gem 'turbulence'
end

Then run it:

bundle exec bule

Watch out, it’ll open a new tab in the browser for you:

''

Caveats

  • It’s just a number. It doesn’t replace human thought, passion, and desires.
  • Only works on Ruby 1.8!
  • Outliers make the plot nearly impossible to read.