mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Safely autocorrect Lint/SafeNavigationChain
Inspecting 1480 files
........................................................................................................................................................................................................................................................................................................................................W............................W..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Offenses:
app/models/spree/line_item.rb:283:55: W: [Corrected] Lint/SafeNavigationChain: Do not chain ordinary method call after safe navigation operator.
self.final_weight_volume = variant&.unit_value * quantity
^^^^^^^^^^^
app/models/spree/line_item.rb:283:57: C: [Corrected] Layout/SpaceAroundMethodCallOperator: Avoid using spaces around a method call operator.
self.final_weight_volume = variant&.unit_value&. * quantity
^
app/models/spree/stock/availability_validator.rb:31:77: W: [Corrected] Lint/SafeNavigationChain: Do not chain ordinary method call after safe navigation operator.
return line_item.order.shipments.first if line_item.order&.shipments.any?
^^^^^
1480 files inspected, 3 offenses detected, 3 offenses corrected
This commit is contained in:
@@ -141,15 +141,6 @@ Lint/RedundantSafeNavigation:
|
||||
Exclude:
|
||||
- 'app/models/spree/payment.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: present?, blank?, presence, try, try!, in?
|
||||
Lint/SafeNavigationChain:
|
||||
Exclude:
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/stock/availability_validator.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
||||
|
||||
@@ -280,7 +280,7 @@ module Spree
|
||||
if final_weight_volume.present? && quantity_was > 0
|
||||
self.final_weight_volume = final_weight_volume * quantity / quantity_was
|
||||
elsif variant&.unit_value.present?
|
||||
self.final_weight_volume = variant&.unit_value * quantity
|
||||
self.final_weight_volume = variant&.unit_value&.* quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ module Spree
|
||||
|
||||
def line_item_shipment(line_item)
|
||||
return line_item.target_shipment if line_item.target_shipment
|
||||
return line_item.order.shipments.first if line_item.order&.shipments.any?
|
||||
return line_item.order.shipments.first if line_item.order&.shipments&.any?
|
||||
end
|
||||
|
||||
# Overrides Spree v2.0.4 validate method version to:
|
||||
|
||||
Reference in New Issue
Block a user