What's a Good Flog Score?

I've been using Flog to measure the complexity of my Ruby code and I was wondering how others interpret Flog numbers. I'll go first with my opinions:

Score of Means
0-10 Awesome
11-20 Good enough
21-40 Might need refactoring
41-60 Possible to justify
61-100 Danger
100-200 Whoop, whoop, whoop
200 + Someone please think of the children

(note: these are scores for an individual method)
The 20 - 60 range is interesting to me. Sometimes the complexity of what you're doing will justify the score and other times the method is in desperate need of refactoring.

The highest Flog score I've seen in the wild was in the 300's. What's you're personal high and what do you think of my rankings?

In other news, I've redesigned the look of my blog so if you only see my post through a reader you might want to stop on by, take a look, and tell me what you think.

Comments

Anonymous said…
are these scores for directories? apps? files?
Jake Scruggs said…
Good point, rsl. These are scores for methods (I just added a note to the original post).
Anonymous said…
sweet. now i don't have to hang my head in shame. ;)
Ben Mabey said…
I like the scale.. it seems to be in line with my observations. I tend to apply different scales to different types of code though. The application layer for example (i.e. controllers) should always be low.
Anonymous said…
Enjoyed your presentation at LSRC. Thanks.
Ran Flog on our codebase. Top of the list:
OrderController#handle_payment: (524.2)
Scary!!
Ryan Davis said…
I've got you all beat. :P

% time flog -n -m */dev/lib | head -25
Total Flog = 32364.8 (13.5 +/- 1057.1 flog / method)

RubyLexer#yylex: (1076.9)
Hoe#define_tasks: (587.2)
Context#debug_command: (498.0)
Anonymous said…
I like the scale.

We've just published a gem which allows you to check your flog scores in unit tests.
http://blog.simplificator.com/2008/09/11/flogger-unit-test-your-flog-scores/
The test fails if your flog score is above 20. Of course you can customize this behaviour (if you run flog on the flogger gem then it will report scores > 20 :-) )
S. Potter said…
I know I am quite late to the comments, but I did want to voice my broad support of your scoring system.

I think you are quite right to point to the 20-60 range as the grey area which strongly depends on your code domain and complexity of the project and requires someone experienced in that system domain to interpret properly.

My highest score across my five active projects so far is 50.4, but after refactoring just now is 33.5. They include 3 web apps (2x Rails, 1x Merb), a catch all internal Rails plugin and Twitter4R (raw Ruby library). Sorry for being boring in comparison to some that have already commented!

I am glad the Ruby community is finally getting on board with using metrics (as part of a holistic approach) to assist in managing software project risk. Coming from a heavy metrics background in Java/J2EE the last 4+ years in Ruby and Python have felt a little too much like the wild west, which has been fun, but perhaps it's time to grow up now!;)

Jake, glad to see people like you taking the metrics [integration] movement forward in the Ruby world. Thanks!
Shane Kretzmann said…
I sincerely appreciate you publishing this scale. I just started using flog. I ran it against my latest gem coded for the company and my most masochistic method was flogged 38 times! I was kinda freaking out since this method is not very complicated at all.. Most of the methods fell under 10 with just a couple others landing between 10 and 15.

I think this is a pretty neat reality check against your code, but it's only useful if you understand the context of the numbers - lol - so thanks!

Popular posts from this blog

Point Inside a Polygon in Ruby

SICP Wasn’t Written for You