---
title: Watch for Turbulence
teaser: Give low complexity to your high-churn code.
tags: web,good code
author: Mike Burns
published_on: 2012-02-24
---

How important is the refactoring you're working on? [Michael Feathers has a
metric](http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=COL&ObjectId=16679&tth=DYN&tt=siteemail&iDyn=2)
you should consider when deciding: plot the complexity against the churn.

Chad Fowler's [turbulence](https://github.com/chad/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](http://ruby.sadi.st/Flog.html).

"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:

![''](https://images.thoughtbot.com/blog-vellum-image-uploads/LLRxtMIVSCKxnZCzjLMS_tumblr_lzutqjbzMl1qztl3j.png)

## 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.
