Flog hates Ruby 1.9

April 19th 2011

I just ran into an interesting issue concerning a conflict between syntax that appears to be valid in the eyes of Ruby 1.9, but not to Flog.

  Section.find_or_create_by(title: "Horse Crap")

This YAML like syntax is new in Ruby 1.9 to create hash literals. I found it in the Mongoid doc.

In Ruby 1.9 one can now create hash literals as

  {a: "b"} => {:a => "b"}

RSpec tests were green as the grass on a Spring sunny day, so I was stunned when our teams local BigTuna belted out a massive crashing noise. Our build failed!!! Upon investigation I found our code complexity test failed, for which we are using Flog to measure. The error output was

  parse error on value ":" (tCOLON)

Unfortunately I am not brave (or foolish) enough to tinker with the Flog source. Instead I chose the high road and adjusted the find_or_create_by to look like

  Section.find_or_create_by(:title => "Horse Crap")