mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Rubocop: Correct Lint/AmbiguousOperator offences
This commit is contained in:
@@ -14,10 +14,6 @@ Bundler/OrderedGems:
|
||||
Exclude:
|
||||
- 'Gemfile'
|
||||
|
||||
# Offense count: 48
|
||||
Lint/AmbiguousOperator:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 8
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith.
|
||||
|
||||
@@ -36,8 +36,8 @@ class ModelSet
|
||||
end
|
||||
|
||||
def save
|
||||
collection_to_delete.each &:destroy
|
||||
collection_to_keep.all? &:save
|
||||
collection_to_delete.each(&:destroy)
|
||||
collection_to_keep.all?(&:save)
|
||||
end
|
||||
|
||||
def collection_to_delete
|
||||
|
||||
@@ -7,7 +7,7 @@ module Spree
|
||||
private
|
||||
|
||||
def refresh_products_cache
|
||||
products(:reload).each &:refresh_products_cache
|
||||
products(:reload).each(&:refresh_products_cache)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,13 +7,13 @@ module Spree
|
||||
private
|
||||
|
||||
def refresh_products_cache
|
||||
variants(:reload).each &:refresh_products_cache
|
||||
variants(:reload).each(&:refresh_products_cache)
|
||||
end
|
||||
|
||||
def refresh_products_cache_from_destroy
|
||||
vs = variants(:reload).to_a
|
||||
yield
|
||||
vs.each &:refresh_products_cache
|
||||
vs.each(&:refresh_products_cache)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -161,7 +161,7 @@ Spree::Order.class_eval do
|
||||
end
|
||||
|
||||
def cap_quantity_at_stock!
|
||||
line_items.each &:cap_quantity_at_stock!
|
||||
line_items.each(&:cap_quantity_at_stock!)
|
||||
end
|
||||
|
||||
def set_distributor!(distributor)
|
||||
|
||||
@@ -216,7 +216,7 @@ Spree::Product.class_eval do
|
||||
if variant_unit_changed?
|
||||
option_types.delete self.class.all_variant_unit_option_types
|
||||
option_types << variant_unit_option_type if variant_unit.present?
|
||||
variants_including_master.each &:update_units
|
||||
variants_including_master.each(&:update_units)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Spree::ProductOptionType.class_eval do
|
||||
def remove_option_values
|
||||
self.product.variants_including_master.each do |variant|
|
||||
option_values = variant.option_values.where(option_type_id: self.option_type)
|
||||
variant.option_values.destroy *option_values
|
||||
variant.option_values.destroy(*option_values)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module Spree
|
||||
private
|
||||
|
||||
def refresh_products_cache
|
||||
product_properties(:reload).each &:refresh_products_cache
|
||||
product_properties(:reload).each(&:refresh_products_cache)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,6 +57,6 @@ Spree::Taxon.class_eval do
|
||||
private
|
||||
|
||||
def refresh_products_cache
|
||||
products(:reload).each &:refresh_products_cache
|
||||
products(:reload).each(&:refresh_products_cache)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,7 +172,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def incoming_variant_ids
|
||||
@order_cycle.supplied_variants.map &:id
|
||||
@order_cycle.supplied_variants.map(&:id)
|
||||
end
|
||||
|
||||
def variants_to_a(variants)
|
||||
|
||||
@@ -6,7 +6,7 @@ module OpenFoodNetwork::Reports
|
||||
|
||||
organise do
|
||||
group { |li| li.product }
|
||||
sort &:name
|
||||
sort(&:name)
|
||||
|
||||
summary_row do
|
||||
column { |lis| "TOTAL" }
|
||||
|
||||
@@ -6,11 +6,11 @@ module OpenFoodNetwork::Reports
|
||||
|
||||
organise do
|
||||
group { |li| li.product.supplier }
|
||||
sort &:name
|
||||
sort(&:name)
|
||||
|
||||
organise do
|
||||
group { |li| li.product }
|
||||
sort &:name
|
||||
sort(&:name)
|
||||
|
||||
summary_row do
|
||||
column { |lis| supplier_name(lis) }
|
||||
|
||||
@@ -24,7 +24,7 @@ module OpenFoodNetwork::Reports
|
||||
rule = rule.next
|
||||
end
|
||||
|
||||
rules.map &:to_h
|
||||
rules.map(&:to_h)
|
||||
end
|
||||
|
||||
# -- DSL
|
||||
|
||||
@@ -97,7 +97,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def tax_included_in(line_item)
|
||||
line_item.adjustments.sum &:included_tax
|
||||
line_item.adjustments.sum(&:included_tax)
|
||||
end
|
||||
|
||||
def shipment_inc_vat
|
||||
|
||||
@@ -12,11 +12,11 @@ module OpenFoodNetwork
|
||||
private
|
||||
|
||||
def completed_order_total
|
||||
completed_orders.sum &:total
|
||||
completed_orders.sum(&:total)
|
||||
end
|
||||
|
||||
def payment_total
|
||||
payments.sum &:amount
|
||||
payments.sum(&:amount)
|
||||
end
|
||||
|
||||
def completed_orders
|
||||
|
||||
@@ -11,7 +11,7 @@ module OpenFoodNetwork
|
||||
def options_text
|
||||
values = self.option_values.joins(:option_type).order("#{Spree::OptionType.table_name}.position asc")
|
||||
|
||||
values.map! &:presentation # This line changed
|
||||
values.map!(&:presentation) # This line changed
|
||||
|
||||
values.to_sentence({ :words_connector => ", ", :two_words_connector => ", " })
|
||||
end
|
||||
|
||||
@@ -175,27 +175,27 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def total_untaxable_products(order)
|
||||
order.line_items.without_tax.sum &:amount
|
||||
order.line_items.without_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_taxable_products(order)
|
||||
order.line_items.with_tax.sum &:amount
|
||||
order.line_items.with_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_untaxable_fees(order)
|
||||
order.adjustments.enterprise_fee.without_tax.sum &:amount
|
||||
order.adjustments.enterprise_fee.without_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_taxable_fees(order)
|
||||
order.adjustments.enterprise_fee.with_tax.sum &:amount
|
||||
order.adjustments.enterprise_fee.with_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_shipping(order)
|
||||
order.adjustments.shipping.sum &:amount
|
||||
order.adjustments.shipping.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_transaction(order)
|
||||
order.adjustments.payment_fee.sum &:amount
|
||||
order.adjustments.payment_fee.sum(&:amount)
|
||||
end
|
||||
|
||||
def tax_on_shipping_s(order)
|
||||
@@ -204,11 +204,11 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def total_untaxable_admin_adjustments(order)
|
||||
order.adjustments.admin.without_tax.sum &:amount
|
||||
order.adjustments.admin.without_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def total_taxable_admin_adjustments(order)
|
||||
order.adjustments.admin.with_tax.sum &:amount
|
||||
order.adjustments.admin.with_tax.sum(&:amount)
|
||||
end
|
||||
|
||||
def detail?
|
||||
|
||||
@@ -181,7 +181,7 @@ feature %q{
|
||||
scenario "updating an order cycle", js: true do
|
||||
# Given an order cycle with all the settings
|
||||
oc = create(:order_cycle)
|
||||
initial_variants = oc.variants.sort_by &:id
|
||||
initial_variants = oc.variants.sort_by(&:id)
|
||||
|
||||
# And a coordinating, supplying and distributing enterprise with some products with variants
|
||||
coordinator = oc.coordinator
|
||||
|
||||
@@ -106,7 +106,7 @@ describe UpdateAccountInvoices do
|
||||
end
|
||||
|
||||
context "that starts in the future" do
|
||||
travel_to -1.days
|
||||
travel_to(-1.days)
|
||||
|
||||
it "snags an error and does not update invoices" do
|
||||
updater.perform
|
||||
|
||||
@@ -10,23 +10,23 @@ module OpenFoodNetwork::Reports
|
||||
header 'One', 'Two', 'Three', 'Four'
|
||||
|
||||
columns do
|
||||
column &P1
|
||||
column &P2
|
||||
column &P3
|
||||
column &P4
|
||||
column(&P1)
|
||||
column(&P2)
|
||||
column(&P3)
|
||||
column(&P4)
|
||||
end
|
||||
|
||||
organise do
|
||||
group &P1
|
||||
sort &P2
|
||||
group(&P1)
|
||||
sort(&P2)
|
||||
|
||||
organise do
|
||||
group &P3
|
||||
sort &P4
|
||||
group(&P3)
|
||||
sort(&P4)
|
||||
|
||||
summary_row do
|
||||
column &P1
|
||||
column &P4
|
||||
column(&P1)
|
||||
column(&P4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,9 +6,9 @@ module OpenFoodNetwork::Reports
|
||||
let(:proc) { Proc.new {} }
|
||||
|
||||
it "can define a number of columns and return them as an array" do
|
||||
row.column &proc
|
||||
row.column &proc
|
||||
row.column &proc
|
||||
row.column(&proc)
|
||||
row.column(&proc)
|
||||
row.column(&proc)
|
||||
|
||||
row.to_a.should == [proc, proc, proc]
|
||||
end
|
||||
|
||||
@@ -6,17 +6,17 @@ module OpenFoodNetwork::Reports
|
||||
let(:proc) { Proc.new {} }
|
||||
|
||||
it "can define a group proc and return it in a hash" do
|
||||
rule.group &proc
|
||||
rule.group(&proc)
|
||||
rule.to_h.should == {group_by: proc, sort_by: nil}
|
||||
end
|
||||
|
||||
it "can define a sort proc and return it in a hash" do
|
||||
rule.sort &proc
|
||||
rule.sort(&proc)
|
||||
rule.to_h.should == {group_by: nil, sort_by: proc}
|
||||
end
|
||||
|
||||
it "can define a nested rule" do
|
||||
rule.organise &proc
|
||||
rule.organise(&proc)
|
||||
rule.next.should be_a Rule
|
||||
end
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ describe TagRule::DiscountOrder, type: :model do
|
||||
it "creates a new adjustment on the order" do
|
||||
tag_rule.send(:apply!)
|
||||
expect(adjustment).to be_a Spree::Adjustment
|
||||
expect(adjustment.amount).to eq -10.00
|
||||
expect(adjustment.amount).to eq(-10.00)
|
||||
expect(adjustment.label).to eq "Discount"
|
||||
expect(order.adjustment_total).to eq -10.00
|
||||
expect(order.adjustment_total).to eq(-10.00)
|
||||
expect(order.total).to eq 90.00
|
||||
end
|
||||
end
|
||||
@@ -83,7 +83,7 @@ describe TagRule::DiscountOrder, type: :model do
|
||||
it "the adjustment is made on line item total, ie. ignores the shipping amount" do
|
||||
tag_rule.send(:apply!)
|
||||
expect(adjustment).to be_a Spree::Adjustment
|
||||
expect(adjustment.amount).to eq -10.00
|
||||
expect(adjustment.amount).to eq(-10.00)
|
||||
expect(adjustment.label).to eq "Discount"
|
||||
expect(order.adjustment_total).to eq 15.00
|
||||
expect(order.total).to eq 115.00
|
||||
|
||||
Reference in New Issue
Block a user