require "rubocop/rake_task"

RuboCop::RakeTask.new(:lint) do |t|
  t.patterns = %w(app bin config Gemfile lib spec)
  t.formatters = %w(clang)
  t.options = %w(--parallel)
end

unless Rails.env.production?
  require "rubocop/rake_task"

  RuboCop::RakeTask.new(:lint) do |t|
    t.patterns = %w(app bin config Gemfile lib spec)
    t.formatters = %w(clang)
    t.options = %w(--parallel)
  end
end

Fix deployment error due to missing rubocop
Fix deployment error due to missing rubocop

rubocop-govuk is only a dev dependency, so this task causes an error when run in production mode:

    15:32:26 *** [err :: backend-2.backend.staging.publishing.service.gov.uk] rake aborted!
    15:32:26 *** [err :: backend-2.backend.staging.publishing.service.gov.uk] LoadError: cannot load such file -- rubocop/rake_task