mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #12547 from zanetagebka/StringConcatenationCops
Fix cops StringConcatenation
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.62.1.
|
||||
# using RuboCop version 1.64.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
||||
Layout/EmptyLineBetweenDefs:
|
||||
Exclude:
|
||||
- 'app/services/products_renderer.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Layout/EmptyLines:
|
||||
Exclude:
|
||||
- 'app/services/products_renderer.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Exclude:
|
||||
- 'app/services/products_renderer.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented
|
||||
Layout/MultilineOperationIndentation:
|
||||
Exclude:
|
||||
- 'app/services/products_renderer.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
||||
Lint/EmptyBlock:
|
||||
@@ -22,11 +51,10 @@ Lint/EmptyBlock:
|
||||
- 'spec/jobs/subscription_placement_job_spec.rb'
|
||||
- 'spec/models/product_import/entry_validator_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Offense count: 4
|
||||
# Configuration parameters: AllowComments.
|
||||
Lint/EmptyClass:
|
||||
Exclude:
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/lib/reports/report_loader_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
@@ -80,7 +108,7 @@ Lint/UselessMethodDefinition:
|
||||
Exclude:
|
||||
- 'app/models/spree/gateway.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Offense count: 24
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
||||
Metrics/AbcSize:
|
||||
Exclude:
|
||||
@@ -102,7 +130,6 @@ Metrics/AbcSize:
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/spree/core/controller_helpers/order.rb'
|
||||
- 'lib/tasks/enterprises.rake'
|
||||
- 'spec/services/orders/checkout_restart_service_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
@@ -123,7 +150,7 @@ Metrics/BlockNesting:
|
||||
Exclude:
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
|
||||
# Offense count: 46
|
||||
# Offense count: 47
|
||||
# Configuration parameters: CountComments, Max, CountAsOne.
|
||||
Metrics/ClassLength:
|
||||
Exclude:
|
||||
@@ -175,7 +202,7 @@ Metrics/ClassLength:
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
|
||||
# Offense count: 34
|
||||
# Offense count: 32
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
||||
Metrics/CyclomaticComplexity:
|
||||
Exclude:
|
||||
@@ -185,7 +212,6 @@ Metrics/CyclomaticComplexity:
|
||||
- 'app/helpers/checkout_helper.rb'
|
||||
- 'app/helpers/order_cycles_helper.rb'
|
||||
- 'app/helpers/spree/admin/navigation_helper.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/product_import/entry_validator.rb'
|
||||
- 'app/models/spree/ability.rb'
|
||||
@@ -206,7 +232,7 @@ Metrics/CyclomaticComplexity:
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/models/product_importer_spec.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# Offense count: 24
|
||||
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
|
||||
Metrics/MethodLength:
|
||||
Exclude:
|
||||
@@ -391,7 +417,6 @@ RSpecRails/HaveHttpStatus:
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/requests/admin/images_spec.rb'
|
||||
- 'spec/requests/api/routes_spec.rb'
|
||||
- 'spec/requests/checkout/failed_checkout_spec.rb'
|
||||
- 'spec/requests/checkout/stripe_sca_spec.rb'
|
||||
- 'spec/requests/home_controller_spec.rb'
|
||||
- 'spec/requests/omniauth_callbacks_controller_spec.rb'
|
||||
@@ -407,7 +432,7 @@ RSpecRails/HttpStatus:
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
|
||||
# Offense count: 146
|
||||
# Offense count: 144
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Inferences.
|
||||
RSpecRails/InferredSpecType:
|
||||
@@ -511,7 +536,6 @@ RSpecRails/InferredSpecType:
|
||||
- 'spec/helpers/navigation_helper_spec.rb'
|
||||
- 'spec/helpers/order_cycles_helper_spec.rb'
|
||||
- 'spec/helpers/serializer_helper_spec.rb'
|
||||
- 'spec/helpers/shared_helper_spec.rb'
|
||||
- 'spec/helpers/shop_helper_spec.rb'
|
||||
- 'spec/helpers/spree/admin/base_helper_spec.rb'
|
||||
- 'spec/helpers/spree/admin/general_settings_helper_spec.rb'
|
||||
@@ -545,7 +569,6 @@ RSpecRails/InferredSpecType:
|
||||
- 'spec/requests/api/routes_spec.rb'
|
||||
- 'spec/requests/api/v1/customers_spec.rb'
|
||||
- 'spec/requests/api_docs_spec.rb'
|
||||
- 'spec/requests/checkout/failed_checkout_spec.rb'
|
||||
- 'spec/requests/checkout/paypal_spec.rb'
|
||||
- 'spec/requests/checkout/routes_spec.rb'
|
||||
- 'spec/requests/checkout/stripe_sca_spec.rb'
|
||||
@@ -758,7 +781,7 @@ Style/CaseEquality:
|
||||
Exclude:
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# Offense count: 23
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: nested, compact
|
||||
@@ -785,7 +808,6 @@ Style/ClassAndModuleChildren:
|
||||
- 'app/serializers/api/taxon_serializer.rb'
|
||||
- 'app/serializers/api/variant_serializer.rb'
|
||||
- 'lib/open_food_network/locking.rb'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/models/spree/payment_method_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
@@ -838,12 +860,6 @@ Style/HashEachMethods:
|
||||
- 'spec/models/product_importer_spec.rb'
|
||||
- 'spec/support/cancan_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinBranchesCount.
|
||||
Style/HashLikeCase:
|
||||
Exclude:
|
||||
- 'app/models/enterprise.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/MapToHash:
|
||||
@@ -939,12 +955,6 @@ Style/RedundantInterpolation:
|
||||
- 'lib/tasks/karma.rake'
|
||||
- 'spec/base_spec_helper.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantLineContinuation:
|
||||
Exclude:
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
|
||||
# Offense count: 19
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
@@ -987,34 +997,10 @@ Style/Send:
|
||||
- 'spec/services/variant_units/option_value_namer_spec.rb'
|
||||
- 'spec/support/localized_number_helper.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/SlicingWithRange:
|
||||
Exclude:
|
||||
- 'app/helpers/spree/admin/navigation_helper.rb'
|
||||
- 'app/services/embedded_page_service.rb'
|
||||
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Mode.
|
||||
Style/StringConcatenation:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/stripe_connect_settings_controller.rb'
|
||||
- 'app/helpers/enterprises_helper.rb'
|
||||
- 'app/helpers/spree/admin/base_helper.rb'
|
||||
- 'app/mailers/spree/user_mailer.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/credit_card.rb'
|
||||
- 'app/models/spree/payment_method.rb'
|
||||
- 'app/serializers/api/cached_enterprise_serializer.rb'
|
||||
- 'app/serializers/api/enterprise_shopfront_list_serializer.rb'
|
||||
- 'app/services/embedded_page_service.rb'
|
||||
- 'app/services/products_renderer.rb'
|
||||
- 'lib/spree/api/controller_setup.rb'
|
||||
- 'lib/spree/core/environment_extension.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
- 'spec/services/embedded_page_service_spec.rb'
|
||||
- 'spec/support/features/datepicker_helper.rb'
|
||||
- 'spec/system/admin/products_spec.rb'
|
||||
|
||||
@@ -37,7 +37,7 @@ module Admin
|
||||
|
||||
def obfuscated_secret_key
|
||||
key = Stripe.api_key
|
||||
key.first(8) + "****" + key.last(4)
|
||||
"#{key.first(8)}****#{key.last(4)}"
|
||||
end
|
||||
|
||||
def settings_params
|
||||
|
||||
@@ -31,7 +31,7 @@ module EnterprisesHelper
|
||||
|
||||
def enterprises_options(enterprises)
|
||||
enterprises.map { |enterprise|
|
||||
[enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city,
|
||||
["#{enterprise.name}: #{enterprise.address.address1}, #{enterprise.address.city}",
|
||||
enterprise.id.to_i]
|
||||
}
|
||||
end
|
||||
|
||||
@@ -108,7 +108,7 @@ module Spree
|
||||
|
||||
object.preferences.keys.map { |key|
|
||||
preference_label = form.label("preferred_#{key}",
|
||||
Spree.t(key.to_s.gsub("_from_list", "")) + ": ")
|
||||
"#{Spree.t(key.to_s.gsub('_from_list', ''))}: ")
|
||||
preference_field = preference_field_for(
|
||||
form,
|
||||
"preferred_#{key}",
|
||||
@@ -120,7 +120,7 @@ module Spree
|
||||
|
||||
def link_to_add_fields(name, target, options = {})
|
||||
name = '' if options[:no_text]
|
||||
css_classes = options[:class] ? options[:class] + " spree_add_fields" : "spree_add_fields"
|
||||
css_classes = options[:class] ? "#{options[:class]} spree_add_fields" : "spree_add_fields"
|
||||
link_to_with_icon('icon-plus',
|
||||
name,
|
||||
'javascript:',
|
||||
|
||||
@@ -25,7 +25,7 @@ module Spree
|
||||
@user = user
|
||||
I18n.with_locale valid_locale(@user) do
|
||||
mail(to: user.email,
|
||||
subject: t(:welcome_to) + ' ' + Spree::Config[:site_name])
|
||||
subject: "#{t(:welcome_to)} #{Spree::Config[:site_name]}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ class Enterprise < ApplicationRecord
|
||||
def category
|
||||
# Make this crazy logic human readable so we can argue about it sanely.
|
||||
cat = is_primary_producer ? "producer_" : "non_producer_"
|
||||
cat << ("sells_" + sells)
|
||||
cat << ("sells_#{sells}")
|
||||
|
||||
# Map backend cases to front end cases.
|
||||
case cat
|
||||
@@ -510,7 +510,7 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def correct_whatsapp_url(phone_number)
|
||||
phone_number && ("https://wa.me/" + phone_number.tr('+ ', ''))
|
||||
phone_number && "https://wa.me/#{phone_number.tr('+ ', '')}"
|
||||
end
|
||||
|
||||
def correct_instagram_url(url)
|
||||
|
||||
@@ -30,7 +30,7 @@ module Spree
|
||||
|
||||
def expiry=(expiry)
|
||||
self[:month], self[:year] = expiry.split(" / ")
|
||||
self[:year] = "20" + self[:year]
|
||||
self[:year] = "20#{self[:year]}"
|
||||
end
|
||||
|
||||
def number=(num)
|
||||
|
||||
@@ -118,7 +118,7 @@ module Spree
|
||||
end
|
||||
|
||||
def self.clean_name
|
||||
i18n_key = "spree.admin.payment_methods.providers." + name.demodulize.downcase
|
||||
i18n_key = "spree.admin.payment_methods.providers.#{name.demodulize.downcase}"
|
||||
I18n.t(i18n_key)
|
||||
end
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ module Api
|
||||
producer_shop: "map_003-producer-shop.svg",
|
||||
producer: "map_001-producer-only.svg",
|
||||
}
|
||||
"/map_icons/" + (icons[enterprise.category] || "map_001-producer-only.svg")
|
||||
"/map_icons/#{icons[enterprise.category] || 'map_001-producer-only.svg'}"
|
||||
end
|
||||
|
||||
# Choose regular icon font for enterprises.
|
||||
|
||||
@@ -21,7 +21,7 @@ module Api
|
||||
producer_shop: "map_003-producer-shop.svg",
|
||||
producer: "map_001-producer-only.svg",
|
||||
}
|
||||
"/map_icons/" + (icons[enterprise.category] || "map_001-producer-only.svg")
|
||||
"/map_icons/#{icons[enterprise.category] || 'map_001-producer-only.svg'}"
|
||||
end
|
||||
|
||||
def icon_font
|
||||
|
||||
@@ -59,7 +59,7 @@ class EmbeddedPageService
|
||||
def set_logout_redirect
|
||||
return unless enterprise_slug
|
||||
|
||||
@session[:shopfront_redirect] = '/' + enterprise_slug + '/shop?embedded_shopfront=true'
|
||||
@session[:shopfront_redirect] = "/#{enterprise_slug}/shop?embedded_shopfront=true"
|
||||
end
|
||||
|
||||
def enterprise_slug
|
||||
|
||||
@@ -68,23 +68,26 @@ class ProductsRenderer
|
||||
end
|
||||
|
||||
def products_order
|
||||
if (distributor.preferred_shopfront_product_sorting_method == "by_producer") &&
|
||||
distributor.preferred_shopfront_producer_order.present?
|
||||
distributor
|
||||
.preferred_shopfront_producer_order
|
||||
.split(",").map { |id| "spree_products.supplier_id=#{id} DESC" }
|
||||
.join(", ") + ", spree_products.name ASC, spree_products.id ASC"
|
||||
if distributor.preferred_shopfront_product_sorting_method == "by_producer" &&
|
||||
distributor.preferred_shopfront_producer_order.present?
|
||||
order_by_producer = distributor
|
||||
.preferred_shopfront_producer_order
|
||||
.split(",").map { |id| "spree_products.supplier_id=#{id} DESC" }
|
||||
.join(", ")
|
||||
"#{order_by_producer}, spree_products.name ASC, spree_products.id ASC"
|
||||
elsif distributor.preferred_shopfront_product_sorting_method == "by_category" &&
|
||||
distributor.preferred_shopfront_taxon_order.present?
|
||||
distributor
|
||||
.preferred_shopfront_taxon_order
|
||||
.split(",").map { |id| "first_variant.primary_taxon_id=#{id} DESC" }
|
||||
.join(", ") + ", spree_products.name ASC, spree_products.id ASC"
|
||||
distributor.preferred_shopfront_taxon_order.present?
|
||||
order_by_category = distributor
|
||||
.preferred_shopfront_taxon_order
|
||||
.split(",").map { |id| "first_variant.primary_taxon_id=#{id} DESC" }
|
||||
.join(", ")
|
||||
"#{order_by_category}, spree_products.name ASC, spree_products.id ASC"
|
||||
else
|
||||
"spree_products.name ASC, spree_products.id"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def variants_for_shop
|
||||
@variants_for_shop ||= begin
|
||||
scoper = OpenFoodNetwork::ScopeVariantToHub.new(distributor)
|
||||
|
||||
@@ -22,7 +22,7 @@ module Spree
|
||||
include CanCan::ControllerAdditions
|
||||
include Spree::Core::ControllerHelpers::Auth
|
||||
|
||||
prepend_view_path Rails.root + "app/views"
|
||||
prepend_view_path "#{Rails.root}app/views"
|
||||
append_view_path File.expand_path("../../../app/views", File.dirname(__FILE__))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,11 +9,11 @@ module Spree
|
||||
instance_variable_set "@#{name}", Set.new
|
||||
|
||||
create_method( :"#{name}=" ) { |val|
|
||||
instance_variable_set( "@" + name, val)
|
||||
instance_variable_set( "@#{name}", val)
|
||||
}
|
||||
|
||||
create_method(name.to_sym) do
|
||||
instance_variable_get( "@" + name )
|
||||
instance_variable_get( "@#{name}" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ module Spree
|
||||
before { allow(li).to receive(:product) { p } }
|
||||
|
||||
context "when full_name starts with the product name" do
|
||||
before { allow(li).to receive(:full_name) { p.name + " - something" } }
|
||||
before { allow(li).to receive(:full_name) { "#{p.name} - something" } }
|
||||
|
||||
it "does not show the product name twice" do
|
||||
expect(li.product_and_full_name).to eq('product - something')
|
||||
|
||||
@@ -11,7 +11,7 @@ module Spree
|
||||
context '#duplicate' do
|
||||
it 'duplicates product' do
|
||||
clone = product.duplicate
|
||||
expect(clone.name).to eq 'COPY OF ' + product.name
|
||||
expect(clone.name).to eq "COPY OF #{product.name}"
|
||||
expect(clone.sku).to eq ""
|
||||
expect(clone.image).to eq product.image
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ RSpec.describe EmbeddedPageService do
|
||||
expect(session[:embedded_shopfront]).to eq true
|
||||
expect(session[:embedding_domain]).to eq 'embedding-enterprise.com'
|
||||
expect(session[:shopfront_redirect])
|
||||
.to eq '/' + enterprise_slug + '/shop?embedded_shopfront=true'
|
||||
.to eq "/#{enterprise_slug}/shop?embedded_shopfront=true"
|
||||
end
|
||||
|
||||
it "publicly reports that embedded layout should be used" do
|
||||
@@ -58,7 +58,7 @@ RSpec.describe EmbeddedPageService do
|
||||
expect(session[:embedded_shopfront]).to eq true
|
||||
expect(session[:embedding_domain]).to eq 'embedding-enterprise.com'
|
||||
expect(session[:shopfront_redirect])
|
||||
.to eq '/' + enterprise_slug + '/shop?embedded_shopfront=true'
|
||||
.to eq "/#{enterprise_slug}/shop?embedded_shopfront=true"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ module Features
|
||||
"select.flatpickr-monthDropdown-months").value.to_i + 1
|
||||
year = find(".flatpickr-calendar.open .flatpickr-current-month " \
|
||||
".numInputWrapper .cur-year").value
|
||||
month.to_s + " " + year.to_s
|
||||
"#{month} #{year}"
|
||||
end
|
||||
|
||||
def pick_datetime(calendar_selector, datetime_selector)
|
||||
|
||||
@@ -690,7 +690,7 @@ RSpec.describe '
|
||||
end
|
||||
|
||||
it "checks error when creating product image with unsupported format" do
|
||||
unsupported_image_file_path = Rails.root + "README.md"
|
||||
unsupported_image_file_path = Rails.root.join("README.md").to_s
|
||||
product = create(:simple_product, supplier: @supplier2)
|
||||
|
||||
image = white_logo_file
|
||||
|
||||
Reference in New Issue
Block a user