How to integrate rubocop with Rake? How to integrate rubocop with Rake? ruby ruby

How to integrate rubocop with Rake?


As of version 0.10.0 rubocop contain a custom rake task that you can use. Just put the following in your Rakefile

require 'rubocop/rake_task'RuboCop::RakeTask.new

Make sure to use upper-case 'R' and 'C' or you will get a NameError.


I highly recommend,

require 'rubocop/rake_task'RuboCop::RakeTask.new(:rubocop) do |t|  t.options = ['--display-cop-names']end

This uses the rubocop's own rake tasks and allows you to pass options if you like.


You will probably find https://github.com/yujinakayama/guard-rubocop useful if you use Guard for your RSpec tests. It enables Rubocop to give you instant feedback as soon as you save the file, along with your test results.