Integration with Other Tools
RuboCop integrates with quite a number of other tools, including editors which may attempt
to do autocorrection for you. In these cases,
rubocop ends up getting called repeatedly,
which may result in some slowness, as
rubocop has to require its entire environment on
You can alleviate some of that boot time by using
rubocop-daemon is a
rubocop that loads everything into a daemonized process so that
subsequent runs save on that boot time after the first execution. Please see the
rubocop-daemon documentation for setup instructions and examples of how to use it
with some editors and other tools.
|RuboCop’s built-in caching should also be used to ensure that source files that have not been changed are not being re-evaluated unnecessarily.|
rubocop.el is a simple Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs and quickly jump between problems in your code.
flycheck > 0.9 also supports RuboCop and uses it by default when available.
If you’re a ST user you might find the Sublime RuboCop plugin useful.
The brackets-rubocop extension displays RuboCop results in Brackets. It can be installed via the extension manager in Brackets.
The lt-rubocop plugin provides LightTable integration.
RuboCop support is available as of the 2017.1 releases.
The ruby extension provides RuboCop integration for Visual Studio Code. RuboCop is also used for the formatting capabilities of this extension.
overcommit is a fully configurable and
extendable Git commit hook manager. To use RuboCop with overcommit, add the
following to your
PreCommit: RuboCop: enabled: true
pre-commit is a framework for managing and maintaining
multi-language pre-commit hooks. To use RuboCop with pre-commit, add the
following to your
- repo: https://github.com/rubocop/rubocop rev: v1.8.1 hooks: - id: rubocop
If your RuboCop configuration uses extensions, be sure to include the gems as
- repo: https://github.com/rubocop/rubocop rev: v1.8.1 hooks: - id: rubocop additional_dependencies: - rubocop-rails - rubocop-rspec
To use RuboCop in your
Rakefile add the following:
require 'rubocop/rake_task' RuboCop::RakeTask.new
If you run
rake -T, the following two RuboCop tasks should show up:
$ rake rubocop # Run RuboCop $ rake rubocop:auto_correct # Autocorrect RuboCop offenses
The above will use default values
require 'rubocop/rake_task' desc 'Run RuboCop on the lib directory' RuboCop::RakeTask.new(:rubocop) do |task| task.patterns = ['lib/**/*.rb'] # only show the files with failures task.formatters = ['files'] # don't abort rake on failure task.fail_on_error = false end