RuboCop is a Ruby code style checker based on the Ruby Style Guide.
RuboCop's installation is pretty standard:
$ gem install rubocop
rubocop with no arguments will check all Ruby source files
in the current folder:
Alternatively you can
rubocop a list of files and folders to check:
$ rubocop app spec lib/something.rb
For more details check the available command-line options:
$ rubocop -h
||Displays the current version and exits|
||Displays some extra debug output|
||Output the results in Emacs format|
||Run with specified config file|
||Suppress the final summary|
The behavior of RuboCop can be controlled via the .rubocop.yml configuration file. The file can be placed either in your home folder or in some project folder.
RuboCop will start looking for the configuration file in the directory it was started in and continue its way up to the home folder.
The file has the following format:
Encoding: Enabled: true LineLength: Enabled: true Max: 79
It allows to enable/disable certain cops (checks) and to alter their behavior if they accept any parameters.
Unfortunately every major Ruby implementation has its own code analysis tooling, which makes the development of a portable code analyzer a daunting task.
RuboCop currently supports MRI 1.9 and MRI 2.0. Support for JRuby and Rubinius is not planned at this point.
Copyright (c) 2012-2013 Bozhidar Batsov. See LICENSE.txt for further details.