From 3f07a8e68cae4f14370a38f29e5285e5620d6816 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Tue, 7 May 2019 15:39:49 +0200 Subject: [PATCH] Only define rubocop tasks in the dev env This broke loading the rake tasks in the production environment as we only have rubocop in development. --- lib/tasks/rubocop.rake | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake index 41ae0865..b575cd54 100644 --- a/lib/tasks/rubocop.rake +++ b/lib/tasks/rubocop.rake @@ -1,16 +1,17 @@ # frozen_string_literal: true -require 'rubocop/rake_task' +unless Rails.env.production? + require 'rubocop/rake_task' -namespace :rubocop do - desc 'Generate .rubocop_todo.yml' - task :auto_gen_config do - sh 'rubocop --display-cop-names --auto-gen-config --auto-gen-only-exclude' + RuboCop::RakeTask.new(:rubocop) do |task| + task.patterns = [] + task.options = ['--display-cop-names'] + end + + namespace :rubocop do + desc 'Generate .rubocop_todo.yml' + task :auto_gen_config do + sh 'rubocop --display-cop-names --auto-gen-config --auto-gen-only-exclude' + end end end - -desc 'Run RuboCop on the whole project' -RuboCop::RakeTask.new(:rubocop) do |task| - task.patterns = [] - task.options = ['--display-cop-names'] -end