Pluralsight blog Where devs, IT admins & creative pros go for news, tips, videos and more.
Pluralsight + Digital-Tutors - 3,000 tech & creative courses - starting at $29/month Get it now →
December 28, 2009

Ruby, Emacs & Flog Metrics

By

One hour screencast.

Only $12!

More info…

Summary
Flog metrics are often difficult to understand. The numbers can’t be compared between projects or even classes. This editor enhancement helps by showing the flog score in the left column as you code.
Flog Score in the Column
This method has a flog score of 22 which can be seen in the column. It’s more meaningful if compared to the scores of other methods in the same class. Larger numbers indicate greater complexity. If one method has a score that is significantly larger than others, it should probably be broken apart into several methods.
Repeated OR
The method repeats a conditional inline many times in the options. Refactoring the optional default value into the metadata method simplifies it and reduces the flog score in real time. (See the screencast linked above.)
Requirements
You’ll need

flog

(sudo gem install flog). The

source

to flog is also available in several SCMs.

Code

Get the code

Inspiration

Gary Bernhardt

wrote the initial Python implementation for Vim and posted a

screencast

that shows it in action. Ignas Mikalajunas

ported

it to Emacs. I used numbers instead of colors since flog scores aren’t absolute (it would be hard to calibrate numbers to colors).

About the Author

is VP of Open Source at Pluralsight. He previously founded PeepCode and is an all around entrepreneur, developer, designer, teacher and athlete. Follow him on Twitter at @topfunky.


Discussion