DEV Community

Andy Zhao (he/him)
Andy Zhao (he/him)

Posted on

Reek - Find your Code Smells!

I recently found out about Reek from watching Sandi Metz's talk from RailsConf 2016 (great intro to code smells btw).

GitHub logo troessner / reek

Code smell detector for Ruby

reek logo

Code smell detector for Ruby

Table of Contents


  • Build Status
  • Gem Version
  • Git Tag
  • Licence
  • Inline docs
  • Code Climate
  • codebeat


Reek is a tool that examines Ruby classes, modules and methods and reports any Code Smells it finds.

For an excellent introduction to Code Smells and Reek check out this blog post or that one. There is also this talk from RubyConfBY (there is also a slide deck if you prefer that).

Install it via rubygems:

gem install reek
Enter fullscreen mode Exit fullscreen mode

and run it like this:

reek [options] [dir_or_source_file]*
Enter fullscreen mode Exit fullscreen mode


Imagine a source file demo.rb containing:

# Smelly
Enter fullscreen mode Exit fullscreen mode

I love tools like these, because you can run them and have the computer tell you what code might be problematic. Also:

  • works with Ruby 2.3, 2.4, 2.5
  • little configuration required for Rails
  • easy config in general
  • has a thorough README

I haven't used it much yet, and it seems to be a fairly popular gem. Have you heard of it? What are your thoughts on it?

Top comments (7)

dstull profile image
Doug Stull

I use it on all my work projects in concert with rubocop. I feel that reek and rubocop are complimentary for the most part; where rubocop cares more about style, and reek cares more about how you code. Where they overlap, I disable one or the other. I also use them during CI for static code analysis through the pre-commit framework, here:

sergio profile image
deleteme deleteme

I think there's a bug, it highlighted my entire ~/Work folder...

ben profile image
Ben Halpern

Looks nice. How does this compare/contrast with other static analysis tools in Ruby?

rhymes profile image

Reek is quite opinionated because it focuses on code smells. It's going to flag lots of stuff in a big codebase like's but it doesn't hurt :-D

There are overlaps with Rubocop IIRC

See the list of code smells. You're probably going to disable Uncommunicative Name for a while because usually it's a high frequency violation.

It might help getting to fewer issues on codeclimate 🤞🏾

ozzyogkush profile image
Derek Rosenzweig

I haven't done Ruby in a bit but when I do I'll add this for sure next time I use it in a project.

chenge profile image
chenge • Edited

Fun, it can be viewed as an expert to learn from. Thanks for share.

tadaboody profile image

Would you look at that.
I'm currently working on a similar tool for python

Tadaboody / good_smell

A linting/refactoring library for python best practices and lesser-known tricks

Good Smell - it makes your code smell good!

A linting/refactoring library for python best practices and lesser-known tricks

Build Status Code style: black PyPi version


pip install good_smell 


good_smell warn - Print warnings about smells in the code

good_smell warn PATH
good_smell warn --path PATH

Alternativly you can run it through flake8. Smells will be with the code SMLxxx

good_smell fix - Print a fixed version of the code

good_smell fix PATH [STARTING_LINE] [END_LINE]
good_smell fix --path PATH [--starting-line STARTING_LINE] [--end-line END_LINE]

Supported code smells:


for i in range(len(sequence))
    x = sequence[i]

will be fixed to

for i, x in enumerate(sequence)

Directly nested for loops

for i in seq_a
    for j in seq_b:
        print(i, j)


import itertools
for i, j in itertools.product(seq_a, seq_b):
    print(i, j)


Clone the repository and run inside it

pip install -e .[dev]

This will install the requirements and…

I'll be looking at this for inspiration. Thanks!