RubyCritic

Gem Version Build Status Code Climate

RubyCritic is a gem that wraps around static analysis gems such as Reek and Flay to provide a quality report of your Ruby code.

This gem provides features such as:

  1. An overview of your project:

RubyCritic overview screenshot

  1. An index of the project files with their respective number of smells:

RubyCritic code index screenshot

  1. An index of the smells detected:

RubyCritic smells index screenshot

  1. Finally, when analysing code like the following:
  class Dirty
    def awful(x, y)
      if y
        @screen = widgets.map {|w| w.each {|key| key += 3}}
      end
    end
  end

It basically turns something like this:

Reek output screenshot

Into something like this:

RubyCritic file code screenshot

Installation

RubyCritic can be installed with the following command:

$ gem install rubycritic

If you'd rather install RubyCritic using Bundler, add this line to your application's Gemfile:

gem "rubycritic", :require => false

And then execute:

$ bundle

Usage

Running rubycritic with no arguments will analyse all the Ruby files in the current directory:

$ rubycritic

Alternatively you can pass rubycritic a list of files and directories to check:

$ rubycritic app lib/foo.rb

By default, RubyCritic generates its report in tmp/rubycritic. You can customize the output directory using the path option. You can use relative paths:

rubycritic --path tmp/custom_dir        # outputs to tmp/custom_dir

Or full paths:

rubycritic --path $HOME/tmp/custom_dir  # outputs to $HOME/tmp/custom_dir

For a full list of the command-line options run:

$ rubycritic --help