Flog shows you the most torturous code you wrote. The more painful the code, the higher the score. The higher the score, the harder it is to test.


Run it against your best stuff. I double-dog dare you.


Flog essentially scores an ABC metric: Assignments, Branches, Calls, with particular attention placed on calls.


Run flog on all your code. Try this:


find lib -name \*.rb | xargs flog


Whatever is at the top of the report is worth looking at.


This is how it works:

Confessions of a Ruby Sadist

sudo gem install flog

class Test

  def blah

    a = eval "1+1"

    if a == 2 then

      puts "yay"

    end

  end

end

Is seen by flog as:

Test#blah: (11.2)

     6.0: eval

     1.2: branch

     1.2: ==

     1.2: puts

     1.2: assignment

     0.4: lit_fixnum

and reported as:

class Test

  def blah         # 11.2 =

    a = eval "1+1" # 1.2 + 6.0 +

    if a == 2 then # 1.2 + 1.2 + 0.4 +

      puts "yay"   # 1.2

    end

  end

end