Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocorrect rubocop Layout/BlockEndNewline cop #2063

Merged
merged 1 commit into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 27 additions & 49 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 1400`
# on 2018-01-20 12:46:57 +0100 using RuboCop version 0.49.1.
# on 2018-02-01 09:48:08 +0100 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -84,26 +84,6 @@ Layout/AlignParameters:
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/support/request/authentication_workflow.rb'

# Offense count: 41
# Cop supports --auto-correct.
Layout/BlockEndNewline:
Exclude:
- 'app/models/order_cycle.rb'
- 'app/models/spree/calculator/default_tax_decorator.rb'
- 'app/models/spree/product_decorator.rb'
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/jobs/update_billable_periods_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/serializers/enterprise_serializer_spec.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
Expand Down Expand Up @@ -138,7 +118,7 @@ Layout/ElseAlignment:
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'lib/open_food_network/sales_tax_report.rb'

# Offense count: 209
# Offense count: 210
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
Expand Down Expand Up @@ -228,6 +208,7 @@ Layout/EmptyLines:
- 'spec/controllers/enterprises_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/checkout_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
- 'spec/factories.rb'
Expand Down Expand Up @@ -531,7 +512,7 @@ Layout/IndentationConsistency:
- 'spec/models/spree/line_item_spec.rb'
- 'spec/models/spree/product_spec.rb'

# Offense count: 19
# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Expand All @@ -544,7 +525,6 @@ Layout/IndentationWidth:
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'lib/discourse/single_sign_on.rb'
- 'serializer.rb'
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
- 'spec/helpers/groups_helper_spec.rb'
Expand Down Expand Up @@ -819,14 +799,15 @@ Layout/SpaceBeforeComma:
- 'spec/features/admin/bulk_order_management_spec.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'

# Offense count: 5
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceBeforeFirstArg:
Exclude:
- 'spec/factories.rb'
- 'spec/features/admin/bulk_product_update_spec.rb'
- 'spec/features/admin/product_import_spec.rb'
- 'spec/features/consumer/multilingual_spec.rb'
- 'spec/models/enterprise_fee_spec.rb'

# Offense count: 1
Expand Down Expand Up @@ -923,7 +904,7 @@ Layout/SpaceInsideBrackets:
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
- 'spec/performance/orders_controller_spec.rb'

# Offense count: 782
# Offense count: 778
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space, compact
Expand Down Expand Up @@ -979,7 +960,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/controllers/admin/business_model_configuration_controller_spec.rb'
- 'spec/controllers/admin/enterprises_controller_spec.rb'
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
- 'spec/controllers/api/enterprises_controller_spec.rb'
- 'spec/controllers/api/statuses_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/checkout_controller_spec.rb'
Expand All @@ -989,7 +969,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
- 'spec/controllers/spree/admin/products_controller_spec.rb'
- 'spec/controllers/spree/admin/reports_controller_spec.rb'
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/controllers/spree/orders_controller_spec.rb'
Expand Down Expand Up @@ -1061,23 +1040,36 @@ Layout/Tab:
- 'spec/lib/spree/product_filters_spec.rb'
- 'spec/models/spree/line_item_spec.rb'

# Offense count: 28
# Offense count: 67
# Cop supports --auto-correct.
Layout/TrailingWhitespace:
Exclude:
- 'app/models/distributor_shipping_method.rb'
- 'app/models/spree/calculator/default_tax_decorator.rb'
- 'app/models/spree/money_decorator.rb'
- 'app/models/spree/product_decorator.rb'
- 'app/serializers/api/image_serializer.rb'
- 'app/serializers/api/shipping_method_serializer.rb'
- 'app/views/json/_current_order.rabl'
- 'app/views/json/_enterprises.rabl'
- 'app/views/json/_producer.rabl'
- 'app/views/json/partials/_producer.rabl'
- 'lib/tasks/dev.rake'
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/features/admin/enterprise_user_spec.rb'
- 'spec/features/admin/variant_overrides_spec.rb'
- 'spec/helpers/enterprises_helper_spec.rb'
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'
- 'spec/lib/open_food_network/permissions_spec.rb'
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
- 'spec/models/order_cycle_spec.rb'
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/serializers/admin/enterprise_serializer_spec.rb'
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/menu_helper.rb'
- 'spec/views/json/producers.json.rabl_spec.rb'

Expand Down Expand Up @@ -1308,7 +1300,7 @@ Lint/Void:
- 'spec/serializers/enterprise_serializer_spec.rb'
- 'spec/support/request/web_helper.rb'

# Offense count: 793
# Offense count: 794
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 672
Expand Down Expand Up @@ -1403,15 +1395,6 @@ Rails/FilePath:
- 'spec/models/spree/variant_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/FindBy:
Exclude:
- 'app/models/product_importer.rb'
- 'app/models/variant_override.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include.
Expand Down Expand Up @@ -1569,7 +1552,7 @@ Style/BarePercentLiterals:
- 'spec/features/admin/variants_spec.rb'
- 'spec/support/request/web_helper.rb'

# Offense count: 208
# Offense count: 207
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Expand Down Expand Up @@ -1650,7 +1633,7 @@ Style/CaseEquality:
- 'app/helpers/angular_form_helper.rb'
- 'spec/models/spree/payment_spec.rb'

# Offense count: 88
# Offense count: 87
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Expand Down Expand Up @@ -1731,7 +1714,6 @@ Style/ClassAndModuleChildren:
- 'lib/open_food_network/reports/report.rb'
- 'lib/open_food_network/reports/row.rb'
- 'lib/open_food_network/reports/rule.rb'
- 'serializer.rb'
- 'spec/controllers/spree/admin/base_controller_spec.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
- 'spec/lib/open_food_network/reports/row_spec.rb'
Expand Down Expand Up @@ -1881,7 +1863,7 @@ Style/GuardClause:
- 'spec/support/request/distribution_helper.rb'
- 'spec/support/request/shop_workflow.rb'

# Offense count: 1233
# Offense count: 1219
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Expand Down Expand Up @@ -1988,15 +1970,13 @@ Style/HashSyntax:
- 'spec/archive/features/consumer/checkout_spec.rb'
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
- 'spec/controllers/admin/stripe_connect_settings_controller_spec.rb'
- 'spec/controllers/api/enterprises_controller_spec.rb'
- 'spec/controllers/api/order_cycles_controller_spec.rb'
- 'spec/controllers/base_controller_spec.rb'
- 'spec/controllers/cart_controller_spec.rb'
- 'spec/controllers/enterprise_confirmations_controller_spec.rb'
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
- 'spec/controllers/spree/api/products_controller_spec.rb'
- 'spec/controllers/spree/api/variants_controller_spec.rb'
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
Expand Down Expand Up @@ -2139,14 +2119,13 @@ Style/NestedParenthesizedCalls:
- 'spec/controllers/shop_controller_spec.rb'
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'

# Offense count: 5
# Offense count: 4
Style/NestedTernaryOperator:
Exclude:
- 'app/serializers/api/admin/product_serializer.rb'
- 'app/serializers/api/admin/variant_serializer.rb'
- 'app/views/spree/api/products/bulk_show.v1.rabl'
- 'app/views/spree/api/variants/bulk_show.v1.rabl'
- 'serializer.rb'

# Offense count: 3
# Cop supports --auto-correct.
Expand Down Expand Up @@ -2440,14 +2419,13 @@ Style/SymbolProc:
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'

# Offense count: 6
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
Style/TernaryParentheses:
Exclude:
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/api/enterprises_controller.rb'
- 'app/controllers/spree/admin/payment_methods_controller_decorator.rb'
- 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb'

Expand Down
3 changes: 2 additions & 1 deletion app/models/order_cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class OrderCycle < ActiveRecord::Base
joins(:exchanges).
merge(Exchange.outgoing).
merge(Exchange.with_product(product)).
select('DISTINCT order_cycles.*') }
select('DISTINCT order_cycles.*')
}

scope :with_distributor, lambda { |distributor|
joins(:exchanges).merge(Exchange.outgoing).merge(Exchange.to_enterprise(distributor))
Expand Down
3 changes: 2 additions & 1 deletion app/models/spree/calculator/default_tax_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def compute_order(order)
per_item_fees_total = order.line_items.sum do |line_item|
calculator.send(:per_item_enterprise_fee_applicators_for, line_item.variant)
.select { |applicator| (!applicator.enterprise_fee.inherits_tax_category && applicator.enterprise_fee.tax_category == rate.tax_category) ||
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category) }
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category)
}
.sum { |applicator| applicator.enterprise_fee.compute_amount(line_item) }
end

Expand Down
6 changes: 4 additions & 2 deletions app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@
# Find products that are distributed by the given order cycle
scope :in_order_cycle, lambda { |order_cycle| with_order_cycles_inner.
merge(Exchange.outgoing).
where('order_cycles.id = ?', order_cycle) }
where('order_cycles.id = ?', order_cycle)
}

scope :in_an_active_order_cycle, lambda { with_order_cycles_inner.
merge(OrderCycle.active).
merge(Exchange.outgoing).
where('order_cycles.id IS NOT NULL') }
where('order_cycles.id IS NOT NULL')
}

scope :by_producer, joins(:supplier).order('enterprises.name')
scope :by_name, order('name')
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/admin/column_preferences_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
{ id: column_preference.id, user_id: user1.id, action_name: "enterprises_index", column_name: 'name', visible: false },
{ id: nil, user_id: user1.id, action_name: "enterprises_index", column_name: 'producer', visible: true },
{ id: nil, user_id: user1.id, action_name: "enterprises_index", column_name: 'status', visible: true }
] }
]
}

context "where I don't own the preferences submitted" do
before do
Expand Down
6 changes: 4 additions & 2 deletions spec/controllers/shop_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@
let!(:tag_rule) { create(:filter_products_tag_rule,
enterprise: distributor,
preferred_customer_tags: "member",
preferred_variant_tags: "members-only") }
preferred_variant_tags: "members-only")
}
let!(:default_tag_rule) { create(:filter_products_tag_rule,
enterprise: distributor,
is_default: true,
preferred_variant_tags: "members-only") }
preferred_variant_tags: "members-only")
}
let(:product1) { { "id" => 1, "name" => 'product 1', "variants" => [{ "id" => 4, "tag_list" => ["members-only"] }] } }
let(:product2) { { "id" => 2, "name" => 'product 2', "variants" => [{ "id" => 5, "tag_list" => ["members-only"] }, {"id" => 9, "tag_list" => ["something"]}] } }
let(:product3) { { "id" => 3, "name" => 'product 3', "variants" => [{ "id" => 6, "tag_list" => ["something-else"] }] } }
Expand Down
9 changes: 6 additions & 3 deletions spec/features/admin/variant_overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
let!(:producer_related) { create(:supplier_enterprise) }
let!(:producer_unrelated) { create(:supplier_enterprise) }
let!(:er1) { create(:enterprise_relationship, parent: producer, child: hub,
permissions_list: [:create_variant_overrides]) }
permissions_list: [:create_variant_overrides])
}
let!(:er2) { create(:enterprise_relationship, parent: producer_related, child: hub,
permissions_list: [:create_variant_overrides]) }
permissions_list: [:create_variant_overrides])
}

context "as an enterprise user" do
let(:user) { create_enterprise_user enterprises: [hub, producer_managed] }
before { quick_login_as user }

describe "selecting a hub" do
let!(:er1) { create(:enterprise_relationship, parent: hub2, child: producer_managed,
permissions_list: [:add_to_order_cycle]) } # This er should not confer ability to create VOs for hub2
permissions_list: [:add_to_order_cycle])
} # This er should not confer ability to create VOs for hub2

it "displays a list of hub choices (ie. only those managed by the user)" do
visit spree.admin_path
Expand Down
12 changes: 8 additions & 4 deletions spec/helpers/enterprises_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
let!(:tag_rule) { create(:filter_shipping_methods_tag_rule,
enterprise: distributor,
preferred_customer_tags: "local",
preferred_shipping_method_tags: "local-delivery") }
preferred_shipping_method_tags: "local-delivery")
}
let!(:default_tag_rule) { create(:filter_shipping_methods_tag_rule,
enterprise: distributor,
is_default: true,
preferred_shipping_method_tags: "local-delivery") }
preferred_shipping_method_tags: "local-delivery")
}
let!(:tagged_sm) { sm1 }
let!(:untagged_sm) { sm2 }

Expand Down Expand Up @@ -142,11 +144,13 @@
let!(:tag_rule) { create(:filter_payment_methods_tag_rule,
enterprise: distributor,
preferred_customer_tags: "trusted",
preferred_payment_method_tags: "trusted") }
preferred_payment_method_tags: "trusted")
}
let!(:default_tag_rule) { create(:filter_payment_methods_tag_rule,
enterprise: distributor,
is_default: true,
preferred_payment_method_tags: "trusted") }
preferred_payment_method_tags: "trusted")
}
let(:tagged_pm) { pm1 }
let(:untagged_pm) { pm2 }

Expand Down
3 changes: 2 additions & 1 deletion spec/jobs/update_billable_periods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ def travel_to(time)
double(:order, total: 10),
double(:order, total: 20),
double(:order, total: 30)
]}
]
}
end

context "when the account invoice is already_complete" do
Expand Down
Loading