Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fix code quality issues (#10488)

Ravi Teja Gannavarapu63e8dd2e2b6d
diff --git a/.deepsource.toml b/.deepsource.toml
new file mode 100644
index 0000000000..a87f430836
--- /dev/null
+++ b/.deepsource.toml
@@ -0,0 +1,20 @@
+version = 1
+
+exclude_patterns = [
+ "**/sandbox/**/*",
+ "**/db/migrate/*",
+ "**/Gemfile",
+ "**/Gemfile.lock",
+ "**/Rakefile",
+ "**/rails",
+ "guides/**/*",
+ "**/*.gemspec",
+ "**/dummy/**/*",
+ "**/vendor/**/*",
+ "**/spec_helper.rb",
+ "**/templates/**/*"
+]
+
+[[analyzers]]
+name = "ruby"
+enabled = true
\ No newline at end of file
diff --git a/core/app/models/spree/log_entry.rb b/core/app/models/spree/log_entry.rb
index b889449099..dd049c7ebc 100644
--- a/core/app/models/spree/log_entry.rb
+++ b/core/app/models/spree/log_entry.rb
@@ -11,7 +11,7 @@ module Spree
end
def parsed_details
- @details ||= YAML.load(details)
+ @details ||= YAML.safe_load(details, [ActiveMerchant::Billing::Response])
end
end
end
diff --git a/core/lib/spree/core/importer/order.rb b/core/lib/spree/core/importer/order.rb
index ebe98b4bc4..bb1921d219 100644
--- a/core/lib/spree/core/importer/order.rb
+++ b/core/lib/spree/core/importer/order.rb
@@ -38,7 +38,7 @@ module Spree
end
end
order.reload
- rescue Exception => e
+ rescue StandardError => e
order.destroy if order&.persisted?
raise e.message
end
@@ -80,7 +80,7 @@ module Spree
adjustments = s.delete(:adjustments_attributes)
create_adjustments_from_params(adjustments, order, shipment)
- rescue Exception => e
+ rescue StandardError => e
raise "Order import shipments: #{e.message} #{s}"
end
end
@@ -115,7 +115,7 @@ module Spree
line_item.save!
end
create_adjustments_from_params(adjustments, order, line_item)
- rescue Exception => e
+ rescue StandardError => e
raise "Order import line items: #{e.message} #{line_item}"
end
end
@@ -132,7 +132,7 @@ module Spree
)
adjustment.save!
adjustment.close!
- rescue Exception => e
+ rescue StandardError => e
raise "Order import adjustments: #{e.message} #{a}"
end
end
@@ -150,7 +150,7 @@ module Spree
payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
payment.save!
- rescue Exception => e
+ rescue StandardError => e
raise "Order import payments: #{e.message} #{p}"
end
end
@@ -167,7 +167,7 @@ module Spree
gateway_payment_profile_id: source_hash[:gateway_payment_profile_id],
imported: true
)
- rescue Exception => e
+ rescue StandardError => e
raise "Order import source payments: #{e.message} #{source_hash}"
end
@@ -179,7 +179,7 @@ module Spree
hash
rescue ActiveRecord::RecordNotFound => e
raise "Ensure order import variant: Variant w/SKU #{sku} not found."
- rescue Exception => e
+ rescue StandardError => e
raise "Ensure order import variant: #{e.message} #{hash}"
end
@@ -200,7 +200,7 @@ module Spree
address.delete(:country)
address[:country_id] = Spree::Country.where(search).first!.id
- rescue Exception => e
+ rescue StandardError => e
raise "Ensure order import address country: #{e.message} #{search}"
end
end
@@ -224,7 +224,7 @@ module Spree
else
address[:state_name] = search[:name] || search[:abbr]
end
- rescue Exception => e
+ rescue StandardError => e
raise "Ensure order import address state: #{e.message} #{search}"
end
end
diff --git a/core/lib/spree/testing_support/i18n.rb b/core/lib/spree/testing_support/i18n.rb
index 6e92b8cab2..fad584c319 100644
--- a/core/lib/spree/testing_support/i18n.rb
+++ b/core/lib/spree/testing_support/i18n.rb
@@ -84,7 +84,7 @@ RSpec.configure do |config|
end
Spree.check_unused_translations
- if false && Spree.unused_translation_messages.any?
+ if Spree.unused_translation_messages.any?
puts "\nThere are unused translations within Spree:"
puts Spree.unused_translation_messages.sort
exit(1)