RuboCop

The Ruby Linter/Formatter that Serves and Protects

View on GitHub Read Docs Style Guide

Overview

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.

Compatibility

RuboCop supports MRI 2.4+ and JRuby 9.2+.

Installation

RuboCop's installation is pretty standard:

$ gem install rubocop

Usage

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 auto-correct offenses with rubocop -a:

$ rubocop -a

Use -h for available command-line options.