Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Ruby Style Guides and Tools: How to Write Good Looking Ruby

By Peter Cooper / October 27, 2008

style.pngLast week, Noel Rappin of Pathfinder Development wrote Elements of Ruby Style - an attempt at producing a Ruby "style guide." After some initial feedback to this, he's followed up with a response to some of the initial criticisms and suggestions.

Noel isn't the first to try to develop a Ruby style guide. In an attempt to promote Ruby's use within Google, Ian Macdonald wrote an extensive Ruby style guide back in 2006 (rather sadly, it appears his attempt did not work out).

What's a "Style Guide" then?

For those unfamiliar with style guides, the most famous for the English language are probably Strunk & White's The Elements of Style and The Chicago Manual of Style (my personal favorite) - both attempt to define how to write and lay out English texts properly. Style guides for programming languages, however, usually attempt to not only define the "correct" way to write and lay out code but also the right idioms to use in certain situations.

Other Tools

Ruby style and "code smells" have become topics of interest for many Ruby developers recently:

  • Last month, Kevin Rutherford released reek, a "code smells detector"
  • Marty Andrews released Roodi, a tool that checks Ruby code for complexity
  • flog is also a popular Ruby tool for testing and showing the complexity of your Ruby code.

Supported by Media72 Hosting: Looking for reliable UK Ruby on Rails hosting? Packages start from just £7/month on our mod_rails/apache stack hosted on fast UK servers and include free 24/7 support.


  1. Giles Bowkett says:

    Blatant self-promotion, and it's still mostly experimental status, but there's also Towelie, my repetition detector. It's on GitHub and my blog. It finds duplicate method definitions effortlessly, and reports them cleanly. It can also find highly similar method definitions, but both the interface and the reporting for that are very clumsy. Lots of rough edges on this code but it works very well for finding cut-and-paste in legacy codebases.

  2. Giles Bowkett says:

    There's also Flay, although the project hasn't released any code yet:

    This is a repetition detector like Towelie, but they didn't just copy the idea. It also can recognize when different code does the same thing, and mark that as repetition. That's something Towelie can't do. Unfortunately it still has unicorn status until they release something. :-p

  3. Eric Duminil says:

    As always, nothing to say about the interesting content.
    But could you please stop leaving colored ads in


  4. Peter Cooper says:

    Eric: Unfortunately I've had to add styles directly to the paragraph because otherwise it doesn't work in feeds. seems to take the code in feeds as verbatim for HTML purposes (which has caused the whole front page to end up in bold today, as someone posted a broken item to their feed) so all that goes through with it. Ideally PlanetRubyOnRails would sanitize the HTML formatting.

  5. Daniel Berger says:

    I find duplicate method definitions with -w.

    And fsck that 2 space indentation crap. Just because that's what the Rails core developers use, doesn't mean you should shut your brain off and do what they do.

    I'm not giving up 3 space indentation. I don't give a crap what the Rails core developers (or Matz) do. My style is my own.

  6. Phil says:

    Personally I love how the Ruby community has unconditionally decided on 2 spaces for indentation. It sidesteps soooo many tedious arguments that other languages are bogged down with.

Other Posts to Enjoy

Twitter Mentions