Recently in RubySadism Category

ParseTree is a C extension (using RubyInline) that extracts the parse tree for an entire class or a specific method and returns it as a s-expression (aka sexp) using ruby's arrays, strings, symbols, and integers.

As an example:

def conditional1(arg1) if arg1 == 0 then return 1 end return 0 end

becomes:

[:defn, :conditional1, [:scope, [:block, [:args, :arg1], [:if, [:call, [:lvar, :arg1], :==, [:array, [:lit, 0]]], [:return, [:lit, 1]], nil], [:return, [:lit, 0]]]]]

  • Uses RubyInline, so it just drops in.
  • Includes SexpProcessor and CompositeSexpProcessor.
    • Allows you to write very clean filters.
  • Includes UnifiedRuby, allowing you to automatically rewrite ruby quirks.
  • ParseTree#parsetreefor_string lets you parse arbitrary strings of ruby.
  • Includes parsetreeshow, which lets you quickly snoop code.
    • echo "1+1" | parsetreeshow -f for quick snippet output.
  • Includes parsetreeabc, which lets you get abc metrics on code.
    • abc metrics = numbers of assignments, branches, and calls.
    • whitespace independent metric for method complexity.
  • Includes parsetreedeps, which shows you basic class level dependencies.
  • Does not work on the core classes, as they are not ruby (yet).

Changes:

  • 2 minor enhancements:

    • Deactivated gcc-specific compiler flags unless ENV['ANAL'] or on my domain.
    • Minor code cleanup - happier with -pedantic and the like.
  • 1 bug fix:

    • FINALLY conquered the splat args bug on certain platforms/versions. Special Thanks to Jonas Pfenniger for debugging this and providing a patch.
  • http://www.zenspider.com/ZSS/Products/ParseTree/

Seattle.rb batting 1000?

| | Comments (1)

I'm not sure yet (still waiting on more responses on the mailing list), but I think that Seattle.rb is batting 1000 for RubyConf2007!!! A big congratulations goes out to:

  • Evan Phoenix - talking about Rubinius.
  • Eric Hodel - giving a talk about Über-Productivity.
  • Phil Hagelberg - giving a talk on tightening the feedback loop.

And, um... my talk... titled:

Hurting Code for Fun and Profit

It should be fun... I hope to see you there!

Flogging the World

| | Comments (1)

Coming out

It is time I come right out and say it...

I am a Ruby Sadist, and I'm OK!

It is true. I like to hurt code. With code I like to hurt systems. It is something I'm good at, I just haven't been able to put it into words very well. Potential employers don't quite understand or empathize when you talk about hurting code, even tho that might be exactly what they're trying to hire you for. They just don't think of it in those terms. To help gather my thoughts, tools, and to communicate my goals more clearly, I've launched ruby.sadi.st. Enjoy...

Flogging the World

Flog 1.1 is out, and with it a lot of enhancements to pointing out code complexity. In particular, it adds full ABC (Assignment, Branches, and Calls) metrics. ABC is a nice, simple whitespace independent way of measuring code that I talked about it in my RubyConf 2005 talk.

Well... I went overboard (again). I flogged every (latest) gem released and poked around. I won't release the full report yet, but here is a bit of a peek:

Statistics:

total # gems      :    1766
total # methods   :  134839
avg methods / gem :   76.35 +/-  170.66
avg flog / project: 1245.47 +/- 3416.56
avg flog / method :   14.06 +/-   32.60

Top 10 Methods per Gem:

 1:       fxruby-1.6.11.gem: 2559 methods,  4.71 +/- 11.33 flog
 2:           bio-1.1.0.gem: 2286 methods, 13.10 +/- 23.22 flog
 3:       puppet-0.23.2.gem: 2044 methods, 15.85 +/- 22.54 flog
 4:       facets-1.8.54.gem: 1962 methods, 11.42 +/- 28.21 flog
 5:        soap4r-1.5.7.gem: 1452 methods, 11.55 +/- 16.59 flog
 6:       bioruby-0.6.4.gem: 1450 methods, 12.04 +/- 22.36 flog
 7:         deplate-0.8.gem: 1426 methods, 14.35 +/- 25.47 flog
 8:           rio-0.4.1.gem: 1291 methods,  6.44 +/- 10.17 flog
 9: activerecord-1.15.3.gem: 1279 methods, 15.12 +/- 26.89 flog
10:   actionpack-1.13.3.gem: 1129 methods, 12.61 +/- 19.95 flog

Most Prolific Developers:

 1:    Daniel J. Berger: 43 projects 11849.9 tot  275.6 avg
 2:       Thomas Sawyer: 43 projects 48329.2 tot 1123.9 avg
 3:          Eric Hodel: 40 projects 36787.0 tot  919.7 avg
 4:       Ara T. Howard: 28 projects 40856.8 tot 1459.2 avg
 5:       Aaron Pfeifer: 19 projects  3733.0 tot  196.5 avg
 6:          Ryan Davis: 18 projects 31990.1 tot 1777.2 avg
 7:      NOT Ryan Davis: 16 projects 15834.9 tot  989.7 avg
 8: Geoffrey Grosenbach: 15 projects  6203.7 tot  413.6 avg
 9:      Erik Hollensbe: 13 projects  2069.0 tot  159.2 avg
10:        Florent Solt: 12 projects  3686.2 tot  307.2 avg

Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.

% ./bin/flog bin/flog
Total score = 128.7

Flog#report: (21)
     4: puts
     2: sort_by
...

Changes:

  • 3 major enhancements:
    • Added assignments and branches and a lot of other stuff. rad.
    • Added process_iter section for DSL style blocks (rake tasks etc).
    • Made Flog usable as a library.
  • 12 minor enhancements:
    • Added -a flag to turn off threshold culling for other tools.
    • Added -s for summarizing the score.
    • Added -v feedback to know what file you're flogging.
    • Added branching penalty so tons of nested conditionals get beat down.
    • Added send (3).
    • Capture and ignore SyntaxErrors from template/generator code. Stupid DHH.
    • Report can now take an IO object.
    • blockargs now penalizes all non-benign forms of blockpass.
    • Added usage to bin/flog. Moved -I processing to bin/flog.
    • Added unpack.rb and updatescores.rb at base level (not installed)
    • Added scoring for blockpass.
    • Converted totals to use distance formula on ABC's.
  • 3 bug fixes:

    • Ran flog on every latest gem available. Found a bunch of problems.
    • Use a stack for both class/module and method accounting.
    • block_args weren't processing the arg
  • http://ruby.sadi.st/

  • http://rubyforge.org/projects/seattlerb

When good tests go bad

| | Comments (0)
4:44 : Chad: All heckling was thwarted! YAY!!!
4:44 : Chad: my sissy unit tests aren't so sissy after all ;)
4:47 : Ryan: or that means that your code is so tightly
             coupled that it all falls apart whenever you
             change anything
4:47 : Chad: ass hat

See Also: Notes on Heckle

#rubinius

| | Comments (0)
12:42 @evan : that Array#===
12:42 @evan : what are people thinking?!
12:42 @evan : if you ask that guy what O(n^2) is, he'll just
              poop his pants

Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.

% ./bin/flog bin/flog
Total score = 128.7

Flog#report: (21)
     4: puts
     2: sort_by
...

Changes:

Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.

% ./bin/flog bin/flog
Total score = 128.7

Flog#report: (21)
     4: puts
     2: sort_by
...

Changes:

Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.

% ./bin/flog bin/flog
Total score = 128.7

Flog#report: (21)
     4: puts
     2: sort_by
...

Changes:

1.0.0 / 2007-08-01

Autotest meets Doom

Autotest with SFX

http://fozworks.com/static/autotest-sound10.html

I really like this last one. It uses well engineered audio to bypass the need for visual interruptions. Hopefully it'll help you keep flow better.