Fix Style/HashSyntax

This commit is contained in:
Neal Chambers
2023-09-16 09:05:31 +09:00
parent 0b4d0a1438
commit 4596997547
30 changed files with 56 additions and 56 deletions

View File

@@ -139,7 +139,7 @@ module OpenFoodNetwork
def calculate_fee_for(variant, enterprise_fee)
# Spree's Calculator interface accepts Orders or LineItems,
# so we meet that interface with a struct.
line_item = OpenStruct.new variant: variant, quantity: 1, price: variant.price,
line_item = OpenStruct.new variant:, quantity: 1, price: variant.price,
amount: variant.price
enterprise_fee.compute_amount(line_item)
end

View File

@@ -35,7 +35,7 @@ module OpenFoodNetwork
return word unless key
I18n.t(key, scope: "inflections", count: count, default: word)
I18n.t(key, scope: "inflections", count:, default: word)
end
private

View File

@@ -24,11 +24,11 @@ module OpenFoodNetwork
if exchange_exists?(exchange[:enterprise_id], @order_cycle.coordinator_id, true)
update_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true,
variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids,
variant_ids:, enterprise_fee_ids:,
receival_instructions: exchange[:receival_instructions] )
else
add_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true,
variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids,
variant_ids:, enterprise_fee_ids:,
receival_instructions: exchange[:receival_instructions], )
end
end
@@ -40,15 +40,15 @@ module OpenFoodNetwork
if exchange_exists?(@order_cycle.coordinator_id, exchange[:enterprise_id], false)
update_exchange(@order_cycle.coordinator_id, exchange[:enterprise_id], false,
variant_ids: variant_ids,
enterprise_fee_ids: enterprise_fee_ids,
variant_ids:,
enterprise_fee_ids:,
pickup_time: exchange[:pickup_time],
pickup_instructions: exchange[:pickup_instructions],
tag_list: exchange[:tag_list] )
else
add_exchange(@order_cycle.coordinator_id, exchange[:enterprise_id], false,
variant_ids: variant_ids,
enterprise_fee_ids: enterprise_fee_ids,
variant_ids:,
enterprise_fee_ids:,
pickup_time: exchange[:pickup_time],
pickup_instructions: exchange[:pickup_instructions],
tag_list: exchange[:tag_list] )
@@ -63,13 +63,13 @@ module OpenFoodNetwork
attr_accessor :touched_exchanges
def exchange_exists?(sender_id, receiver_id, incoming)
@order_cycle.exchanges.where(sender_id: sender_id, receiver_id: receiver_id,
incoming: incoming).present?
@order_cycle.exchanges.where(sender_id:, receiver_id:,
incoming:).present?
end
def add_exchange(sender_id, receiver_id, incoming, attrs = {})
attrs = attrs.reverse_merge(sender_id: sender_id, receiver_id: receiver_id,
incoming: incoming)
attrs = attrs.reverse_merge(sender_id:, receiver_id:,
incoming:)
variant_ids = attrs.delete :variant_ids
exchange = @order_cycle.exchanges.build attrs
@@ -82,8 +82,8 @@ module OpenFoodNetwork
end
def update_exchange(sender_id, receiver_id, incoming, attrs = {})
exchange = @order_cycle.exchanges.where(sender_id: sender_id, receiver_id: receiver_id,
incoming: incoming).first
exchange = @order_cycle.exchanges.where(sender_id:, receiver_id:,
incoming:).first
return unless permission_for(exchange)
remove_unauthorized_exchange_attributes(exchange, attrs)
@@ -148,7 +148,7 @@ module OpenFoodNetwork
def find_exchange(sender_id, receiver_id, incoming)
@order_cycle.exchanges.
find_by(sender_id: sender_id, receiver_id: receiver_id, incoming: incoming)
find_by(sender_id:, receiver_id:, incoming:)
end
def incoming_exchange_variant_ids(attrs)

View File

@@ -19,7 +19,7 @@ module OpenFoodNetwork
end
def price_in(currency)
Spree::Price.new(amount: price, currency: currency)
Spree::Price.new(amount: price, currency:)
end
# Uses variant_override.count_on_hand instead of Stock::Quantifier.stock_items.count_on_hand

View File

@@ -43,7 +43,7 @@ module Reporting
def translate_header(key)
# Quite some headers use currency interpolation, so providing it by default
default_params = { currency: currency_symbol, currency_symbol: currency_symbol }
default_params = { currency: currency_symbol, currency_symbol: }
report.custom_headers[key] || I18n.t("report_header_#{key}", **default_params)
end

View File

@@ -55,7 +55,7 @@ module Reporting
def to_html(layout: nil)
ApplicationController.render(
template: "admin/reports/_table",
layout: layout,
layout:,
locals: { report: @report }
)
end

View File

@@ -42,7 +42,7 @@ module Reporting
@computed_data = report.query_result.map { |item|
row = @builder.build_row(item)
OpenStruct.new(item: item, full_row: row, row: @builder.slice_and_format_row(row))
OpenStruct.new(item:, full_row: row, row: @builder.slice_and_format_row(row))
}
@computed_data.uniq! { |data| data.row.to_h.values } if @report.skip_duplicate_rows?

View File

@@ -7,7 +7,7 @@ module Reporting
attr_accessor :parameters
def initialize(user, params = {}, render: false)
super(user, params, render: render)
super(user, params, render:)
end
def search
@@ -45,9 +45,9 @@ module Reporting
.filter(&method(:filter_enterprise_fee_by_owner))
.map do |enterprise_fee_id, enterprise_fee_adjustment_ids|
{
enterprise_fee_id: enterprise_fee_id,
enterprise_fee_adjustment_ids: enterprise_fee_adjustment_ids,
order: order
enterprise_fee_id:,
enterprise_fee_adjustment_ids:,
order:
}
end
end
@@ -88,7 +88,7 @@ module Reporting
tax_rate_ids << nil if tax_rate_ids.empty?
tax_rate_ids.map do |tax_rate_id|
{
tax_rate_id: tax_rate_id,
tax_rate_id:,
enterprise_fee_id: item[:enterprise_fee_id],
order: item[:order],
}
@@ -234,7 +234,7 @@ module Reporting
query = Spree::Adjustment.tax
query = query.where(included: true) unless included.nil?
query = query.where(originator_id: tax_rate_id(query_result_row)) unless all == true
query.where(order_id: order_id)
query.where(order_id:)
.where(adjustable_type: 'Spree::Adjustment')
.where(adjustable_id: adjustment_ids)
.pick("sum(amount)") || 0

View File

@@ -7,7 +7,7 @@ module Reporting
attr_accessor :permissions, :parameters
def initialize(user, params = {}, render: false)
super(user, params, render: render)
super(user, params, render:)
@parameters = Parameters.new(params.fetch(:q, {}))
@parameters.validate!
@permissions = Permissions.new(user)

View File

@@ -16,7 +16,7 @@ module Reporting
customers: customers_report_types,
products_and_inventory: products_and_inventory_report_types,
users_and_enterprises: [],
enterprise_fee_summary: enterprise_fee_summary,
enterprise_fee_summary:,
order_cycle_management: order_cycle_management_report_types,
sales_tax: sales_tax_report_types,
xero_invoices: xero_report_types,

View File

@@ -72,7 +72,7 @@ module Reporting
end
def customer_code(email)
customer = Customer.where(email: email).first
customer = Customer.where(email:).first
customer.nil? ? "" : customer.code
end
end

View File

@@ -15,7 +15,7 @@ module Reporting
total_cost: proc { |line_items| line_items.sum(&:amount) },
sku: variant_sku,
producer_charges_sales_tax?: supplier_charges_sales_tax?,
product_tax_category: product_tax_category
product_tax_category:
}
end

View File

@@ -22,7 +22,7 @@ module Reporting
group_by: proc { |_item, row| row_header(row) },
header: true,
fields_used_in_header: [:first_name, :last_name, :customer_code, :phone],
summary_row: summary_row,
summary_row:,
}
]
end

View File

@@ -27,7 +27,7 @@ module Reporting
group_by: proc { |_item, row| "#{row.product} - #{row.variant}" },
header: true,
fields_used_in_header: [:product, :variant],
summary_row: summary_row,
summary_row:,
header_class: "h3",
}
]

View File

@@ -20,7 +20,7 @@ module Reporting
{
group_by: :supplier,
header: true,
summary_row: summary_row,
summary_row:,
summary_row_label: I18n.t('admin.reports.total_by_supplier').upcase
},
{
@@ -28,7 +28,7 @@ module Reporting
header: true,
header_class: 'h4',
fields_used_in_header: [:first_name, :last_name, :customer_code, :phone],
summary_row: summary_row,
summary_row:,
summary_row_class: "",
summary_row_label: I18n.t('admin.reports.total_by_customer')
}

View File

@@ -33,8 +33,8 @@ module Reporting
tax_rate_ids << nil if tax_rate_ids.empty?
tax_rate_ids.map do |tax_rate_id|
{
tax_rate_id: tax_rate_id,
order: order
tax_rate_id:,
order:
}
end
end

View File

@@ -27,7 +27,7 @@ module Reporting
line_item.tax_rates.map do |tax_rate|
{
tax_rate_id: tax_rate.id,
line_item: line_item
line_item:
}
end
end.group_by do |hash|
@@ -81,8 +81,8 @@ module Reporting
line_item.adjustments.eligible.tax.sum(&:amount)
end.sum
{
total_excl_tax: total_excl_tax,
tax: tax,
total_excl_tax:,
tax:,
total_incl_tax: total_excl_tax + tax
}
end

View File

@@ -19,7 +19,7 @@ module ActionController
!ApplicationController.spree_responders[self.class.to_s.to_sym].try(:[],
action_name.to_sym)
if action = options.delete(:action)
render action: action
render(action:)
else
defined_response.call
end

View File

@@ -25,7 +25,7 @@ module Stripe
StripeAccount.create(
stripe_user_id: token.stripe_user_id,
stripe_publishable_key: token.stripe_publishable_key,
enterprise: enterprise
enterprise:
)
end

View File

@@ -16,7 +16,7 @@ module Stripe
Stripe::CreditCardCloneFinder.new(card, stripe_account).find_cloned_card
next unless customer_id
stripe_customer = Stripe::Customer.retrieve(customer_id, stripe_account: stripe_account)
stripe_customer = Stripe::Customer.retrieve(customer_id, stripe_account:)
stripe_customer.delete if stripe_customer && !stripe_customer.deleted?
end
end

View File

@@ -11,7 +11,7 @@ module Stripe
return nil unless fingerprint = fingerprint_for_card(@card)
return nil unless email = @card.user&.email
customers = Stripe::Customer.list({ email: email, limit: 100 },
customers = Stripe::Customer.list({ email:, limit: 100 },
stripe_account: @stripe_account)
customers.auto_paging_each do |customer|

View File

@@ -29,7 +29,7 @@ module Stripe
def stripe_account_id
enterprise_id = payment.payment_method&.preferred_enterprise_id
StripeAccount.find_by(enterprise_id: enterprise_id)&.stripe_user_id
StripeAccount.find_by(enterprise_id:)&.stripe_user_id
end
def raise_if_last_payment_error_present(payment_intent_response)

View File

@@ -10,8 +10,8 @@ module Addressing
address1: parts[0],
city: parts[1],
zipcode: parts[2],
state: state,
country: country
state:,
country:
)
end

View File

@@ -14,7 +14,7 @@ module SampleData
name = data[:name]
log "- #{name}"
data[:long_description] = data[:long_description].strip_heredoc.tr("\n", " ")
Enterprise.create_with(data).find_or_create_by!(name: name)
Enterprise.create_with(data).find_or_create_by!(name:)
end
end

View File

@@ -52,7 +52,7 @@ module SampleData
def create_order_cycle(name, coordinator_name, supplier_names, distributor_names, data)
coordinator = Enterprise.find_by(name: coordinator_name)
return if OrderCycle.active.where(name: name).exists?
return if OrderCycle.active.where(name:).exists?
log "- #{name}"
cycle = create_order_cycle_with_fee(name, coordinator)
@@ -61,10 +61,10 @@ module SampleData
def create_order_cycle_with_fee(name, coordinator)
cycle = OrderCycle.create!(
name: name,
name:,
orders_open_at: 1.day.ago,
orders_close_at: 1.month.from_now,
coordinator: coordinator
coordinator:
)
cycle.coordinator_fees << coordinator.enterprise_fees.first
cycle

View File

@@ -48,8 +48,8 @@ module SampleData
def create_payment_method(provider_class, enterprise, name, description, calculator)
payment_method = provider_class.new(
name: name,
description: description,
name:,
description:,
environment: Rails.env,
distributor_ids: [enterprise.id]
)

View File

@@ -33,11 +33,11 @@ module SampleData
password = Spree::User.friendly_token
log "- #{email}"
user = Spree::User.create_with(
password: password,
password:,
password_confirmation: password,
confirmation_sent_at: Time.zone.now,
confirmed_at: Time.zone.now
).find_or_create_by!(email: email)
).find_or_create_by!(email:)
[name, user]
end
end

View File

@@ -22,7 +22,7 @@ namespace :ofn do
puts "Last edited on #{subscription.updated_at}"
puts "Canceled at #{subscription.canceled_at} and paused at #{subscription.paused_at}"
ProxyOrder.where(order_cycle_id: order_cycle_id,
ProxyOrder.where(order_cycle_id:,
subscription_id: subscription.id).each do |proxy_order|
puts
puts "Proxy Order #{proxy_order.id}"

View File

@@ -19,7 +19,7 @@ namespace :ofn do
# Reset Proxy Orders of the Order Cycle
# by detatching them from existing orders and resetting placed and confirmed dates
ProxyOrder.find_by(order_cycle_id: order_cycle_id)&.update!(
ProxyOrder.find_by(order_cycle_id:)&.update!(
order_id: nil,
confirmed_at: nil,
placed_at: nil)

View File

@@ -4,7 +4,7 @@ require 'spec_helper'
describe FeatureToggleConstraint do
subject { described_class.new("baking") }
let(:request) { double(env: env) }
let(:request) { double(env:) }
let(:env) { {} }
it "constraints an unknown feature" do