Flog Your Code
Just came across Flog, a fun profiling tool that weighs your functions and assigns scores. The higher the score the (likely) more complex the function is.
Or, as the Ruby Sadist puts it:
Flog shows you the most torturous code you wrote. The more painful the code, the higher the score.
I’m amused and somewhat pleased to see that on my newest Rails project this distinction still falls to an external library, namely acts_as_authenticated, the sort of result I’d expect to see on most Rails projects.
AuthenticatedSystem#get_auth_data: (25.9)
6.4: []
4.8: branch
3.8: assignment
3.8: request
3.4: env
2.8: split
1.7: decode64
1.5: to_s
1.3: ==
1.3: has_key?
1.2: blank?
1.2: detect
0.5: lit_fixnum
AuthenticatedSystem#login_from_cookie: (21.1)
5.4: assignment
4.8: branch
4.5: cookies
3.2: current_user
2.7: []
1.4: remember_me
1.4: remember_token
1.4: remember_token_expires_at
1.4: flash
1.3: remember_token?
1.3: logged_in?
1.2: find_by_remember_token
AuthenticatedTestHelper#authorize_as: (14.5)
3.0: content_type
3.0: accept
3.0: assignment
3.0: env
1.9: users
1.7: login
1.5: encode64
1.3: branch
I suspect it’d be more interesting and enlightening to run this against a stand-alone Ruby app instead. Alas I do not yet have any that are more than a couple classes and a few functions in length, not worth the effort.