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 a full list of command-line options see the Reek wiki or run
$ reek --help
Imagine a source file csv_writer.rb
containing:
class CsvWriter def write_line(fields) if (fields.length == 0) puts else write_field(fields[0]) 1.upto(fields.length-1) do |i| print "," write_field(fields[i]) end puts end end #... end
Reek will report the following code smells in this file:
$ reek csv_writer.rb CsvWriter#write_line calls fields.length multiple times (Duplication) CsvWriter#write_line has approx 6 statements (Long Method) CsvWriter#write_line/block has the variable name 'i' (Uncommunicative Name)
Reek currently includes checks for some aspects of the following smells:
…and more. See the Reek wiki for up to date details of exactly what Reek will check in your code.
Reek integrates with many of your favourite tools:
-
Use
Reek::RakeTask
to easily add Reek to your Rakefile -
Use
Reek::Spec
to add theshould_not reek
custom matcher to your Rspec examples -
Reek is fully compliant with Ruby 1.8.6, 1.8.7 and 1.9.1
Reek makes use of the following other gems:
-
ruby_parser
-
sexp_processor
-
ruby2ruby
Find out more about Reek from any of the following sources:
-
Browse the Reek documentation at wiki.github.com/kevinrutherford/reek
-
Browse the code or install the latest cutting-edge beta version from github.com/kevinrutherford/reek/tree
-
Read the code API at rdoc.info/projects/kevinrutherford/reek