reek, a code smells detector for ruby

To complement the imminent (ie. sometime next year) publication of the Refactoring in Ruby I’ve been working on a little software tool called ‘reek’. Reek scans ruby code — either source files or in-memory Class objects — looking for some of the code smells discussed in the book. Right now it can detect (certain forms of):

  • Long Method
  • Large Class
  • Feature Envy
  • Uncommunicative Name
  • Long Parameter List
  • Utility Function
  • Nested Iterators

As time goes by I’ll be adding checks for more smells, and I hope to make the current checks a bit more sophisticated. But in the agile spirit of going ugly early, the current very early version is available for you to experiment with. To get the tool:

gem install reek

To run it:

reek file1.rb file2.rb ...

If you try it, please let me know what you think and what you’d like the next version to do!

You can browse the reek project’s code repository at or, both of which are clones of the same Git repository.

Other Ruby tools operating in this same space include Marty Andrews’ Roodi, and flay and flog from the seattle.rb folks. All of these tools have been made possible by the excellent ParseTree gem from the amazingly productive folks at seattle.rb. Looks like Ruby code quality is a hot topic right now, which I think is great news.

28 thoughts on “reek, a code smells detector for ruby

  1. Hi Kevin,

    I am looking for help in using Ruby to automate Delphi applications. These client server applications that we are trying to automate is written using Borland Delphi version 5.

    Can you provide me some links or documentation for the same. I have a lot of website talk abt using Ruby for WEB based application testing.

    Thanks very much

  2. Pingback: … So We Built One :: Code smell detectors for Ruby

  3. Hi, kevin.

    I’m a beginner to ruby and refactoring and a fan of code analysis tools, so I love reek. Thanks for your contribution!

    reek is really helpful for my learning process in both topics. Every smell detected in my code is studied and corrected. But there is a smell that I can’t completely figure out. It’s when reek says:

    [Feature Envy] System#to_s uses @rows more than self

    I’m always think that @rows is the same as self.rows. Could you explain me this smell?

    Thanks, Gabriel

  4. Pingback: reek and feature envy « silk and spinach

  5. Hi!

    rubygems.rb:142:in `activate’: can’t activate ParseTree (= 2.1.1, runtime), already activated ParseTree-2.2.0 (Gem::Exception)

    I think I have a newer version of ParseTree, should that be a problem? Does this really need version ParseTree version=2.1.1? If yes, maybe the gem spec should install it for me? If not, maybe we need a >= 2.1.1?

    Really looking forward to using it!!


  6. Oh one more thing, does it not run on Windows? After i fixed (read updated) my ZenTest,ParseTree and the RubyInline gems to the latest version i got past the above error.

    However now the error is
    c:/ruby/lib/ruby/gems/1.8/gems/RubyInline-3.8.0/lib/inline.rb:578:in “’: No such file or directory – cl -nologo -LD -MD -Zi -O2b2xg- -G6 -I c:/ruby/lib/ruby/1.8/i386-mswin32 -I c:/ruby/include -Lc:/ruby/lib -o “c:\\.ruby_inline/Inl” “c:/.ruby_inline/Inline_RawParseTree_fa12.c” -link /LIBPATH:”c:/ruby/lib” /DEFAULTLIB:”msvcrt-ruby18.lib” /INCREMENTAL:no /EXPORT:Init_Inline_RawParseTree_fa12 (Errno::ENOENT)

    Although, I tried it on my ubuntu version and it


  7. @Aditya: Yeah, I get the same thing. I develop on Ubuntu, but it certainly used to work on Windows with earlier versions of ParseTree. I’ll investigate over the weekend, but right now it looks like ParseTree has stopped working on Windows…

  8. Pingback: เร็วส์ หกสิบหก » นั่งเทียนเขียนข่าว#20

  9. Pingback: Ruby Style Guides and Tools: How to Write Good Looking Ruby

  10. Pingback: ESPN Dev Blog » Blog Archive » Ruby Style Guides and Tools

  11. Hey Kevin, this is insanely awesome. I love it. Do you run it on Rails controllers at all? I’m unsure of the seriousness of Feature Envy and Utility Function warnings there. I’m going to look at the code. It might make sense to have wrapper classes which configure or weight the evaluations, e.g., Feature Envy is OK in all controllers, Utility Function is OK in application controller, neither one is OK in a model, etc. I’m kind of undecided as to whether or not it’s a good idea, though. What do you think?

  12. Kevin,
    Very nice. Much needed!

    I’m getting dozens of warnings like:

    (string):47: warning: useless use of == in void context

    I’m using the latest ParseTree (and probably the latest of the other gems…) on OS X.

    Also, it looks like the output doesn’t list the file with the flagged issue.

  13. @Dean: I often get the same warnings; they usually occur when I accidentally let reek look at rspec files. Try passing a set of files on the command line, or change to a folder where reek can’t see your tests — does that help?

  14. Pingback: » Детектор “плохих запа … QAлификация

  15. hi,
    thanx for such a nice tool :) i just forked your code on GitHub. added an interesting feature.

    now i can apply my own custom rules in ruby code and configure them over *.reek configuration file. please have a look on it –

    i wanted to check more strict variable convention. such as “is_found = …” “can_found = …” or “user_Name = …” kinda variable names will be treated as convention error.

    “is/can/has” etc can’t be used in variable name more over no one can mistakenly use upper case in variable name, ie. “useR_name”

    best wishes, thnx for nice work.

  16. Pingback: TMTC 19 – Kevin Rutherford Interview | Teachmetocode Podcast

  17. Pingback: TMTC 19 – Kevin Rutherford Interview — Teach Me To Code Podcast

  18. Pingback: TMTC 19 – Kevin Rutherford Interview | Teach Me To Code

  19. Pingback: TMTC 19 – Kevin Rutherford Interview -

  20. Pingback: Essential Ruby gems? - Programming Tutorial

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s