Skip to content
This repository

Welcome to the home of Reek, the code smell detector for Ruby!

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

gem install reek

and run it like this:

reek [options] [dir_or_source_file]*

For more information see Command-Line Options or run

reek --help

Example

Imagine a source file demo.rb containing:

class Dirty
  # This method smells of :reek:NestedIterators but ignores them
  def awful(x, y, offset = 0, log = false)
    puts @screen.title
    @screen = widgets.map {|w| w.each {|key| key += 3}}
    puts @screen.contents
  end
end

Reek will report the following code smells in this file:

$ reek demo.rb
spec/samples/demo/demo.rb -- 6 warnings:
  Dirty has no descriptive comment (IrresponsibleModule)
  Dirty#awful has 4 parameters (LongParameterList)
  Dirty#awful has boolean parameter 'log' (ControlCouple)
  Dirty#awful has the parameter name 'x' (UncommunicativeName)
  Dirty#awful has the parameter name 'y' (UncommunicativeName)
  Dirty#awful has the variable name 'w' (UncommunicativeName)
  Dirty#awful has unused parameter 'log' (UnusedParameters)
  Dirty#awful has unused parameter 'offset' (UnusedParameters)
  Dirty#awful has unused parameter 'x' (UnusedParameters)
  Dirty#awful has unused parameter 'y' (UnusedParameters)

Features

Reek currently includes checks for some aspects of Control Couple, Data Clump, Feature Envy, Large Class, Long Parameter List, Simulated Polymorphism, Too Many Statements, Uncommunicative Name, Unused Parameters and more. See the Code Smells for up to date details of exactly what Reek will check in your code.

Integration

Basically there are two ways to use reek in your project except for the obvious static code analysis:

(1) Use Reek’s Rake Task to easily add Reek to your Rakefile
(2) Add Reek’s custom matcher to your Rspec examples like this:

require 'rubygems'
require 'spec'
require 'reek'
require 'reek/spec'
include Reek::Spec

'foo'.should == 'foo' and puts 'foo equals foo'
'foo'.should_not reek and puts 'foo does not reek'

Note the `include..` line.

Dependencies

Reek makes use of the following other gems:

  • ruby_parser
  • sexp_processor
  • ruby2ruby

Learn More

Find out more about Reek from any of the following sources:

I want to …

or…

or…

Something went wrong with that request. Please try again.