From 11081ab1d61397c938b27b98dfc22f55c4131d82 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Mon, 23 Apr 2018 12:51:09 +0200 Subject: [PATCH] Autocorrect Rubocop's Layout/CommentIndentation cop --- .rubocop_todo.yml | 7 ----- Guardfile | 40 +------------------------ lib/open_food_network/packing_report.rb | 6 ---- script/rubocop_autocorrect | 10 +++++++ 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 72bef1c9922..e94f716a1fe 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -84,13 +84,6 @@ Layout/AlignParameters: - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 8 -# Cop supports --auto-correct. -Layout/CommentIndentation: - Exclude: - - 'Guardfile' - - 'lib/open_food_network/packing_report.rb' - # Offense count: 8 # Cop supports --auto-correct. Layout/ElseAlignment: diff --git a/Guardfile b/Guardfile index 9dc491669ea..4ae1efda602 100644 --- a/Guardfile +++ b/Guardfile @@ -5,45 +5,7 @@ guard 'livereload' do watch(%r{app/views/.+\.(erb|haml|slim)$}) watch(%r{app/helpers/.+\.rb}) watch(%r{public/.+\.(css|js|html)}) - #watch(%r{config/locales/.+\.yml}) + # Rails Assets Pipeline watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" } end - - -#guard 'rails' do - #watch('Gemfile.lock') - #watch(%r{^(config|lib)/.*}) -#end - - -#guard 'zeus' do - ## uses the .rspec file - ## --colour --fail-fast --format documentation --tag ~slow - #watch(%r{^spec/.+_spec\.rb$}) - #watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - #watch(%r{^app/(.+)\.haml$}) { |m| "spec/#{m[1]}.haml_spec.rb" } - #watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - #watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] } -#end - -#guard :rspec do - #watch(%r{^spec/.+_spec\.rb$}) - #watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - #watch('spec/spec_helper.rb') { "spec" } - - ## Rails example - #watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - #watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - #watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } - #watch(%r{^spec/support/(.+)\.rb$}) { "spec" } - #watch('config/routes.rb') { "spec/routing" } - #watch('app/controllers/application_controller.rb') { "spec/controllers" } - - ## Capybara features specs - #watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } - - ## Turnip features and steps - #watch(%r{^spec/acceptance/(.+)\.feature$}) - #watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } -#end diff --git a/lib/open_food_network/packing_report.rb b/lib/open_food_network/packing_report.rb index 4c9eb783ecf..d24048fcf6c 100644 --- a/lib/open_food_network/packing_report.rb +++ b/lib/open_food_network/packing_report.rb @@ -59,9 +59,6 @@ def table_items def rules if is_by_customer? -# customer_rows orders -# table_items = @line_items - [ { group_by: proc { |line_item| line_item.order.distributor }, sort_by: proc { |distributor| distributor.name } }, @@ -84,9 +81,6 @@ def rules sort_by: proc { |full_name| full_name } } ] else -# supplier_rows orders -# table_items = supplier_rows orders -# [ { group_by: proc { |line_item| line_item.order.distributor }, sort_by: proc { |distributor| distributor.name } }, { group_by: proc { |line_item| line_item.product.supplier }, diff --git a/script/rubocop_autocorrect b/script/rubocop_autocorrect index 1ca248ddfa5..f9e7cac2fcf 100755 --- a/script/rubocop_autocorrect +++ b/script/rubocop_autocorrect @@ -1,5 +1,15 @@ #!/bin/sh +# Usage +# +# 1. Clean any git unstagged or untracked changes. Consider creating a new branch +# 2. Remove a cop's exclusion paragraph from the .rubocop_todo.yml +# 3. Run: +# +# $ ./script/rubocop_autocorrect +# +# This will commit all the changes. + set -e COP="$1"