mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-27 21:06:49 +00:00
Use rubocop auto correct to fix Style/SafeNavigation issue
This commit is contained in:
@@ -60,7 +60,7 @@ module Spree
|
||||
def destroy_at_stripe
|
||||
stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id, {})
|
||||
|
||||
stripe_customer.delete if stripe_customer
|
||||
stripe_customer&.delete
|
||||
end
|
||||
|
||||
def stripe_account_id
|
||||
|
||||
@@ -166,7 +166,7 @@ module Spree
|
||||
# recalculates the shipment taxes
|
||||
def update_totals_and_taxes
|
||||
@order.updater.update_totals
|
||||
@order.shipment.ensure_correct_adjustment_with_included_tax if @order.shipment
|
||||
@order.shipment&.ensure_correct_adjustment_with_included_tax
|
||||
end
|
||||
|
||||
# Sets the adjustments to open to perform the block's action and restores
|
||||
|
||||
@@ -2,7 +2,7 @@ module I18nHelper
|
||||
def set_locale
|
||||
# Save a given locale
|
||||
if params[:locale] && available_locale?(params[:locale])
|
||||
spree_current_user.update!(locale: params[:locale]) if spree_current_user
|
||||
spree_current_user&.update!(locale: params[:locale])
|
||||
cookies[:locale] = params[:locale]
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class ProducerProperty < ActiveRecord::Base
|
||||
default_scope { order("#{table_name}.position") }
|
||||
|
||||
def property_name
|
||||
property.name if property
|
||||
property&.name
|
||||
end
|
||||
|
||||
def property_name=(name)
|
||||
|
||||
@@ -154,21 +154,21 @@ module ProductImport
|
||||
def unit_fields_validation(entry)
|
||||
unit_types = ['g', 'kg', 't', 'ml', 'l', 'kl', '']
|
||||
|
||||
unless entry.units && entry.units.present?
|
||||
unless entry.units&.present?
|
||||
mark_as_invalid(entry, attribute: 'units', error: I18n.t('admin.product_import.model.blank'))
|
||||
end
|
||||
|
||||
return if import_into_inventory?
|
||||
|
||||
# unit_type must be valid type
|
||||
if entry.unit_type && entry.unit_type.present?
|
||||
if entry.unit_type&.present?
|
||||
unit_type = entry.unit_type.to_s.strip.downcase
|
||||
mark_as_invalid(entry, attribute: 'unit_type', error: I18n.t('admin.product_import.model.incorrect_value')) unless unit_types.include?(unit_type)
|
||||
return
|
||||
end
|
||||
|
||||
# variant_unit_name must be present if unit_type not present
|
||||
mark_as_invalid(entry, attribute: 'variant_unit_name', error: I18n.t('admin.product_import.model.conditional_blank')) unless entry.variant_unit_name && entry.variant_unit_name.present?
|
||||
mark_as_invalid(entry, attribute: 'variant_unit_name', error: I18n.t('admin.product_import.model.conditional_blank')) unless entry.variant_unit_name&.present?
|
||||
end
|
||||
|
||||
def variant_of_product_validation(entry)
|
||||
@@ -372,8 +372,7 @@ module ProductImport
|
||||
|
||||
def inventory_permission?(enterprise_id, producer_id)
|
||||
@current_user.admin? ||
|
||||
( @inventory_permissions[enterprise_id] &&
|
||||
@inventory_permissions[enterprise_id].include?(producer_id) )
|
||||
( @inventory_permissions[enterprise_id]&.include?(producer_id) )
|
||||
end
|
||||
|
||||
def mark_as_invalid(entry, options = {})
|
||||
|
||||
@@ -190,7 +190,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def staged_import?
|
||||
@import_settings && @import_settings.key?(:start) && @import_settings.key?(:end)
|
||||
@import_settings&.key?(:start) && @import_settings.key?(:end)
|
||||
end
|
||||
|
||||
def init_permissions
|
||||
@@ -224,7 +224,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def rows
|
||||
return [] unless @sheet && @sheet.last_row
|
||||
return [] unless @sheet&.last_row
|
||||
|
||||
(2..@sheet.last_row).map do |i|
|
||||
@sheet.row(i)
|
||||
|
||||
@@ -33,7 +33,7 @@ class ProxyOrder < ActiveRecord::Base
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, Time.zone.now)
|
||||
order.cancel if order
|
||||
order&.cancel
|
||||
true
|
||||
end
|
||||
end
|
||||
@@ -43,7 +43,7 @@ class ProxyOrder < ActiveRecord::Base
|
||||
|
||||
transaction do
|
||||
update_column(:canceled_at, nil)
|
||||
order.resume if order
|
||||
order&.resume
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,11 +92,9 @@ module Discourse
|
||||
payload[k] = val
|
||||
end
|
||||
|
||||
if @custom_fields
|
||||
@custom_fields.each do |k, v|
|
||||
@custom_fields&.each do |k, v|
|
||||
payload["custom.#{k}"] = v.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Rack::Utils.build_query(payload)
|
||||
end
|
||||
|
||||
@@ -44,9 +44,7 @@ FactoryBot.define do
|
||||
subscription
|
||||
order_cycle { subscription.order_cycles.first }
|
||||
before(:create) do |proxy_order, _proxy|
|
||||
if proxy_order.order
|
||||
proxy_order.order.update_attribute(:order_cycle_id, proxy_order.order_cycle_id)
|
||||
end
|
||||
proxy_order.order&.update_attribute(:order_cycle_id, proxy_order.order_cycle_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user