The Ruby Linter/Formatter that Serves and Protects

View on GitHub Read Docs Style Guide


RuboCop is a Ruby code style checker (linter) and formatter based on the community-driven Ruby Style Guide.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options. In practice RuboCop supports pretty much every (reasonably popular) coding style that you can think of.

Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.


RuboCop's installation is pretty standard:

$ gem install rubocop

If you'd rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'rubocop', require: false


Running rubocop with no arguments will check all Ruby source files in the current directory:

$ rubocop

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

$ rubocop app spec lib/something.rb

You can emulate the behavior of ruby -wc as well:

$ rubocop -l

You can autocorrect offenses with rubocop -a:

$ rubocop -a

You can limit autocorrect to layout/formatting-related offenses with rubocop -x:

$ rubocop -x

RuboCop can do way more. Use -h to view all available command-line options.


RuboCop supports MRI 2.7+ and JRuby 9.4+.