mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #11300 from macanudo527/fix_rubocop_layout_3
Fix rubocop layout 4
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.54.2.
|
||||
# using RuboCop version 1.55.0.
|
||||
# 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
|
||||
@@ -34,16 +34,6 @@ Layout/LineLength:
|
||||
- 'spec/system/consumer/shopping/cart_spec.rb'
|
||||
- 'spec/system/consumer/shopping/products_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Lint/AmbiguousOperatorPrecedence:
|
||||
Exclude:
|
||||
- 'app/models/calculator/flexi_rate.rb'
|
||||
- 'app/models/enterprise.rb'
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/line_item.rb'
|
||||
- 'app/models/spree/preferences/store.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: enums
|
||||
@@ -134,12 +124,6 @@ Lint/NonAtomicFileOperation:
|
||||
Exclude:
|
||||
- 'app/services/bulk_invoice_service.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Lint/RedundantCopDisableDirective:
|
||||
Exclude:
|
||||
- 'app/components/product_component.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/RedundantDirGlobSort:
|
||||
@@ -157,22 +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.
|
||||
Lint/UnusedMethodArgument:
|
||||
Exclude:
|
||||
- 'lib/reporting/queries/query_interface.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/UselessMethodDefinition:
|
||||
@@ -435,31 +403,6 @@ Naming/AccessorMethodName:
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
|
||||
# Offense count: 42
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, BlockForwardingName.
|
||||
# SupportedStyles: anonymous, explicit
|
||||
Naming/BlockForwarding:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/link_helper.rb'
|
||||
- 'app/helpers/spree/admin/base_helper.rb'
|
||||
- 'app/reflexes/application_reflex.rb'
|
||||
- 'app/services/cache_service.rb'
|
||||
- 'app/services/current_order_locker.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/spree/core/controller_helpers/respond_with.rb'
|
||||
- 'lib/spree/core/delegate_belongs_to.rb'
|
||||
- 'lib/spree/core/environment_extension.rb'
|
||||
- 'spec/models/enterprise_caching_spec.rb'
|
||||
- 'spec/support/embedded_pages_helper.rb'
|
||||
- 'spec/support/preferences_helper.rb'
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
- 'spec/support/request/ui_component_helper.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
- 'spec/swagger_helper.rb'
|
||||
- 'spec/system/support/capybara_setup.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: ForbiddenDelimiters.
|
||||
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
||||
@@ -1144,7 +1087,7 @@ Style/HashAsLastArrayItem:
|
||||
- 'app/components/products_table_component.rb'
|
||||
|
||||
# Offense count: 12
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowSplatArgument.
|
||||
Style/HashConversion:
|
||||
Exclude:
|
||||
|
||||
@@ -20,7 +20,7 @@ class ProductComponent < ViewComponentReflex::Component
|
||||
@product.id
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def column_value(column)
|
||||
case column
|
||||
when 'name'
|
||||
@@ -47,7 +47,7 @@ class ProductComponent < ViewComponentReflex::Component
|
||||
format_date(@product.import_date)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@ module ApplicationHelper
|
||||
end.join("\n").html_safe
|
||||
end
|
||||
|
||||
def ng_form_for(name, *args, &block)
|
||||
def ng_form_for(name, *args, &)
|
||||
options = args.extract_options!
|
||||
|
||||
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &block)
|
||||
form_for(name, *(args << options.merge(builder: AngularFormBuilder)), &)
|
||||
end
|
||||
|
||||
# Pass URL helper calls on to spree where applicable so that we don't need to use
|
||||
# spree.foo_path in any view rendered from non-spree-namespaced controllers.
|
||||
def method_missing(method, *args, &block)
|
||||
def method_missing(method, *args, &)
|
||||
if method.to_s.end_with?('_path', '_url') && spree.respond_to?(method)
|
||||
spree.public_send(method, *args)
|
||||
else
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module LinkHelper
|
||||
def link_to_service(baseurl, name, html_options = {}, &block)
|
||||
def link_to_service(baseurl, name, html_options = {}, &)
|
||||
return if name.blank?
|
||||
|
||||
html_options = html_options.merge target: '_blank'
|
||||
link_to ext_url(baseurl, name), html_options, &block
|
||||
link_to(ext_url(baseurl, name), html_options, &)
|
||||
end
|
||||
|
||||
def ext_url(prefix, url)
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
module Spree
|
||||
module Admin
|
||||
module BaseHelper
|
||||
def field_container(model, method, options = {}, &block)
|
||||
def field_container(model, method, options = {}, &)
|
||||
css_classes = options[:class].to_a
|
||||
css_classes << 'field'
|
||||
if error_message_on(model, method).present?
|
||||
css_classes << 'withError'
|
||||
end
|
||||
content_tag(:div,
|
||||
capture(&block),
|
||||
capture(&),
|
||||
class: css_classes.join(' '),
|
||||
id: "#{model}_#{method}_field")
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module Calculator
|
||||
private
|
||||
|
||||
def compute_for(count)
|
||||
count * preferred_additional_item.to_f + preferred_first_item.to_f
|
||||
(count * preferred_additional_item.to_f) + preferred_first_item.to_f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -359,7 +359,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
|
||||
@@ -493,7 +493,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)
|
||||
|
||||
@@ -24,10 +24,10 @@ module Spree
|
||||
can [:index, :read], Country
|
||||
can :create, Order
|
||||
can :read, Order do |order, token|
|
||||
order.user == user || order.token && token == order.token
|
||||
order.user == user || (order.token && token == order.token)
|
||||
end
|
||||
can :update, Order do |order, token|
|
||||
order.user == user || order.token && token == order.token
|
||||
order.user == user || (order.token && token == order.token)
|
||||
end
|
||||
can [:index, :read], Product
|
||||
can [:index, :read], ProductProperty
|
||||
|
||||
@@ -202,7 +202,7 @@ module Spree
|
||||
|
||||
fees = adjustments.enterprise_fee.sum(:amount)
|
||||
|
||||
(price + fees / quantity).round(2)
|
||||
(price + (fees / quantity)).round(2)
|
||||
end
|
||||
|
||||
def single_display_amount_with_adjustments
|
||||
@@ -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
|
||||
|
||||
@@ -25,7 +25,7 @@ module Spree
|
||||
|
||||
def exist?(key)
|
||||
@cache.exist?(key) ||
|
||||
should_persist? && Spree::Preference.where(key: key).exists?
|
||||
(should_persist? && Spree::Preference.where(key: key).exists?)
|
||||
end
|
||||
|
||||
def get(key, fallback = nil)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -26,8 +26,8 @@ class ApplicationReflex < StimulusReflex::Reflex
|
||||
Spree::Ability.new(current_user)
|
||||
end
|
||||
|
||||
def with_locale(&block)
|
||||
I18n.with_locale(current_user.locale, &block)
|
||||
def with_locale(&)
|
||||
I18n.with_locale(current_user.locale, &)
|
||||
end
|
||||
|
||||
def morph_admin_flashes
|
||||
|
||||
@@ -5,15 +5,15 @@ class CacheService
|
||||
FILTERS_EXPIRY = 30.seconds.freeze
|
||||
SHOPS_EXPIRY = 15.seconds.freeze
|
||||
|
||||
def self.cache(cache_key, options = {}, &block)
|
||||
Rails.cache.fetch cache_key.to_s, options, &block
|
||||
def self.cache(cache_key, options = {}, &)
|
||||
Rails.cache.fetch(cache_key.to_s, options, &)
|
||||
end
|
||||
|
||||
# Yields a cached query, expired by the most recently updated record for a given class.
|
||||
# E.g: if *any* Spree::Taxon record is updated, all keys based on Spree::Taxon will auto-expire.
|
||||
def self.cached_data_by_class(cache_key, cached_class, &block)
|
||||
Rails.cache.fetch "#{cache_key}-#{cached_class}-#{latest_timestamp_by_class(cached_class)}",
|
||||
&block
|
||||
def self.cached_data_by_class(cache_key, cached_class, &)
|
||||
Rails.cache.fetch("#{cache_key}-#{cached_class}-#{latest_timestamp_by_class(cached_class)}",
|
||||
&)
|
||||
end
|
||||
|
||||
# Gets the :updated_at value of the most recently updated record for a given class, and returns
|
||||
@@ -22,10 +22,10 @@ class CacheService
|
||||
cached_class.maximum(:updated_at).to_f
|
||||
end
|
||||
|
||||
def self.home_stats(statistic, &block)
|
||||
def self.home_stats(statistic, &)
|
||||
Rails.cache.fetch("home_stats_count_#{statistic}",
|
||||
expires_in: HOME_STATS_EXPIRY,
|
||||
race_condition_ttl: 10, &block)
|
||||
race_condition_ttl: 10, &)
|
||||
end
|
||||
|
||||
module FragmentCaching
|
||||
|
||||
@@ -9,8 +9,8 @@ class CurrentOrderLocker
|
||||
#
|
||||
# https://guides.rubyonrails.org/action_controller_overview.html#filters
|
||||
#
|
||||
def self.around(controller, &block)
|
||||
lock_order_and_variants(controller.current_order, &block)
|
||||
def self.around(controller, &)
|
||||
lock_order_and_variants(controller.current_order, &)
|
||||
end
|
||||
|
||||
# Locking will not prevent all access to these rows. Other processes are
|
||||
|
||||
@@ -15,11 +15,11 @@ module Reporting
|
||||
NamedFunction.new("SUM", [coalesce(field, default)])
|
||||
end
|
||||
|
||||
def sum_grouped(field, default = 0)
|
||||
def sum_grouped(field, _default = 0)
|
||||
Case.new(sql_grouping(grouping_fields)).when(0).then(field.maximum).else(field.sum)
|
||||
end
|
||||
|
||||
def sum_new(field, default = 0)
|
||||
def sum_new(field, _default = 0)
|
||||
Case.new(sql_grouping(grouping_fields)).when(0).then(field.maximum).else(sum_values(field))
|
||||
end
|
||||
|
||||
|
||||
@@ -389,8 +389,8 @@ module Reporting
|
||||
end
|
||||
end
|
||||
|
||||
def chain_to_scope(&block)
|
||||
@scope = @scope.instance_eval(&block)
|
||||
def chain_to_scope(&)
|
||||
@scope = @scope.instance_eval(&)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ require 'spree/responder'
|
||||
|
||||
module ActionController
|
||||
class Base
|
||||
def respond_with(*resources, &block)
|
||||
def respond_with(*resources, &)
|
||||
if self.class.mimes_for_respond_to.empty?
|
||||
raise "In order to use respond_with, first you need to declare the formats your " \
|
||||
"controller responds to in the class level"
|
||||
end
|
||||
|
||||
return unless (collector = retrieve_collector_from_mimes(&block))
|
||||
return unless (collector = retrieve_collector_from_mimes(&))
|
||||
|
||||
options = resources.size == 1 ? {} : resources.extract_options!
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ module DelegateBelongsTo
|
||||
|
||||
private
|
||||
|
||||
def class_def(name, method = nil, &blk)
|
||||
class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
|
||||
def class_def(name, method = nil, &)
|
||||
class_eval { method.nil? ? define_method(name, &) : define_method(name, method) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def create_method(name, &block)
|
||||
self.class.__send__(:define_method, name, &block)
|
||||
def create_method(name, &)
|
||||
self.class.__send__(:define_method, name, &)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -141,7 +141,7 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
|
||||
def later(&block)
|
||||
Timecop.travel(1.day.from_now, &block)
|
||||
def later(&)
|
||||
Timecop.travel(1.day.from_now, &)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
module OpenFoodNetwork
|
||||
module EmbeddedPagesHelper
|
||||
def on_embedded_page(&block)
|
||||
within_frame :frame, &block
|
||||
def on_embedded_page(&)
|
||||
within_frame(:frame, &)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,12 +8,12 @@ module PreferencesHelper
|
||||
# config.site_name = "my fancy pants store"
|
||||
# end
|
||||
#
|
||||
def reset_spree_preferences(&config_block)
|
||||
def reset_spree_preferences(&)
|
||||
Spree::Preferences::Store.instance.persistence = false
|
||||
Spree::Preferences::Store.instance.clear_cache
|
||||
|
||||
config = Rails.application.config.spree.preferences
|
||||
configure_spree_preferences(&config_block) if block_given?
|
||||
configure_spree_preferences(&) if block_given?
|
||||
end
|
||||
|
||||
def configure_spree_preferences
|
||||
|
||||
@@ -84,10 +84,10 @@ module ShopWorkflow
|
||||
wait_for_cart
|
||||
end
|
||||
|
||||
def within_variant(variant = nil, &block)
|
||||
def within_variant(variant = nil, &)
|
||||
selector = variant ? "#variant-#{variant.id}" : ".variants"
|
||||
expect(page).to have_selector selector
|
||||
within(selector, &block)
|
||||
within(selector, &)
|
||||
end
|
||||
|
||||
def open_bulk_quantity_modal(variant)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module UIComponentHelper
|
||||
def browse_as_small(&block)
|
||||
browse_with_window_size(640, 480, &block)
|
||||
def browse_as_small(&)
|
||||
browse_with_window_size(640, 480, &)
|
||||
end
|
||||
|
||||
def browse_as_medium(&block)
|
||||
browse_with_window_size(1024, 768, &block)
|
||||
def browse_as_medium(&)
|
||||
browse_with_window_size(1024, 768, &)
|
||||
end
|
||||
|
||||
def browse_as_default(&block)
|
||||
|
||||
@@ -49,8 +49,8 @@ module WebHelper
|
||||
end
|
||||
end
|
||||
|
||||
def within_row(num, &block)
|
||||
within("table.index tbody tr:nth-child(#{num})", &block)
|
||||
def within_row(num, &)
|
||||
within("table.index tbody tr:nth-child(#{num})", &)
|
||||
end
|
||||
|
||||
def select2_select(value, options)
|
||||
|
||||
@@ -74,8 +74,8 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
module RswagExtension
|
||||
def param(args, &block)
|
||||
public_send(:let, args) { instance_eval(&block) }
|
||||
def param(args, &)
|
||||
public_send(:let, args) { instance_eval(&) }
|
||||
end
|
||||
end
|
||||
Rswag::Specs::ExampleGroupHelpers.prepend RswagExtension
|
||||
|
||||
@@ -17,7 +17,7 @@ Capybara.save_path = ENV.fetch("CAPYBARA_ARTIFACTS", "./tmp/capybara")
|
||||
Capybara.singleton_class.prepend(Module.new do
|
||||
attr_accessor :last_used_session
|
||||
|
||||
def using_session(name, &block)
|
||||
def using_session(name, &)
|
||||
self.last_used_session = name
|
||||
super
|
||||
ensure
|
||||
|
||||
Reference in New Issue
Block a user