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:
- An overview of your project:
- An index of the project files with their respective number of smells:
- An index of the smells detected:
- 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:
Into something like this:
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
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