From 04400e0289ab4baf7d6c7947ae9e8fa213a516c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Mar 2021 05:26:45 +0000 Subject: [PATCH 1/8] Bump rubocop from 1.11.0 to 1.12.0 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.11.0...v1.12.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6133697ee7..fb9d145a48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -480,7 +480,7 @@ GEM rswag-ui (2.4.0) actionpack (>= 3.1, < 7.0) railties (>= 3.1, < 7.0) - rubocop (1.11.0) + rubocop (1.12.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) From 0133cb4d226e7b88185110b7d3a90903aac98ad7 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 17:40:09 +1100 Subject: [PATCH 2/8] Update deprecated Rubocop option --- .rubocop_manual_todo.yml | 2 +- .rubocop_styleguide.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 934e12057c..de3decbbbe 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -468,7 +468,7 @@ Metrics/AbcSize: Metrics/BlockLength: Max: 25 - ExcludedMethods: [ + IgnoredMethods: [ "class_eval", "collection", "context", diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 6a8818ca77..7199c65857 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -183,7 +183,7 @@ Metrics/AbcSize: Metrics/BlockLength: Max: 25 - ExcludedMethods: [ + IgnoredMethods: [ "class_eval", "collection", "context", From f2103e923f56872ef25578e73c088e5c9af6f5f6 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 17:41:05 +1100 Subject: [PATCH 3/8] Update Rails version for Rubocop --- .rubocop_styleguide.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 7199c65857..7ae9ca8360 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -5,7 +5,7 @@ # rubocop locally, the default configuration file `.rubocop.yml` loads # our "todo lists" to ignore all current violations. AllCops: - TargetRailsVersion: 4.0 + TargetRailsVersion: 5.0 Exclude: - 'bin/**/*' - 'db/**/*' From 74fce2d2f18c455ffb14abda6f4df2262c64cc4f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 17:41:45 +1100 Subject: [PATCH 4/8] Disable new Rubo-Cops We have enough violations already. Let's add them as we see fit and avoid the warnings for now. --- .rubocop_styleguide.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 7ae9ca8360..7376331178 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -5,6 +5,7 @@ # rubocop locally, the default configuration file `.rubocop.yml` loads # our "todo lists" to ignore all current violations. AllCops: + NewCops: disable TargetRailsVersion: 5.0 Exclude: - 'bin/**/*' From 853b250afac598a284f50e39051fceb145e10737 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 17:44:46 +1100 Subject: [PATCH 5/8] Disable Rubocop suggestions to avoid noise --- .rubocop_styleguide.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 7376331178..7cf8fdf518 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -6,6 +6,7 @@ # our "todo lists" to ignore all current violations. AllCops: NewCops: disable + SuggestExtensions: false TargetRailsVersion: 5.0 Exclude: - 'bin/**/*' From 852147bf4512957b451a27ca15597af3bb3218bb Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 17:47:42 +1100 Subject: [PATCH 6/8] Update Rubocop todo lists --- .rubocop_manual_todo.yml | 85 +++++ .rubocop_todo.yml | 775 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 802 insertions(+), 58 deletions(-) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index de3decbbbe..4789dca9fe 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -21,6 +21,25 @@ Layout/LineLength: Max: 100 Exclude: + - app/controllers/spree/admin/products_controller.rb + - app/controllers/spree/admin/reports_controller.rb + - app/controllers/spree/paypal_controller.rb + - engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb + - engines/order_management/spec/services/order_management/order/updater_spec.rb + - engines/order_management/spec/services/order_management/reports/bulk_coop/bulk_coop_report_spec.rb + - lib/open_food_network/reports/line_items.rb + - spec/controllers/spree/admin/orders/invoices_spec.rb + - spec/controllers/spree/admin/tax_rates_controller_spec.rb + - spec/controllers/user_passwords_controller_spec.rb + - spec/features/admin/configuration/general_settings_spec.rb + - spec/features/consumer/shopping/unit_price_spec.rb + - spec/helpers/admin/orders_helper_spec.rb + - spec/lib/open_food_network/order_cycle_management_report_spec.rb + - spec/lib/stripe/authorize_response_patcher_spec.rb + - spec/services/bulk_invoice_service_spec.rb + - spec/services/content_sanitizer_spec.rb + - spec/services/process_payment_intent_spec.rb + - spec/support/features/datepicker_helper.rb - app/controllers/admin/bulk_line_items_controller.rb - app/controllers/admin/contents_controller.rb - app/controllers/admin/customers_controller.rb @@ -329,6 +348,29 @@ Layout/LineLength: Metrics/AbcSize: Max: 15 Exclude: + - app/controllers/admin/schedules_controller.rb + - app/controllers/checkout_controller.rb + - app/controllers/spree/admin/general_settings_controller.rb + - app/controllers/spree/admin/images_controller.rb + - app/controllers/spree/admin/mail_methods_controller.rb + - app/controllers/spree/admin/shipping_methods_controller.rb + - app/controllers/spree/paypal_controller.rb + - app/helpers/spree/base_helper.rb + - app/jobs/subscription_placement_job.rb + - app/models/order_cycle.rb + - app/models/product_import/unit_converter.rb + - app/models/spree/gateway/pay_pal_express.rb + - app/serializers/api/admin/enterprise_serializer.rb + - app/services/order_factory.rb + - app/services/variants_stock_levels.rb + - engines/order_management/app/services/order_management/subscriptions/form.rb + - lib/open_food_network/enterprise_fee_calculator.rb + - lib/open_food_network/order_grouper.rb + - lib/spree/core/controller_helpers/auth.rb + - lib/spree/core/controller_helpers/common.rb + - lib/spree/core/product_duplicator.rb + - lib/stripe/authorize_response_patcher.rb + - lib/stripe/profile_storer.rb - app/controllers/admin/bulk_line_items_controller.rb - app/controllers/admin/customers_controller.rb - app/controllers/admin/enterprise_fees_controller.rb @@ -482,6 +524,8 @@ Metrics/BlockLength: "scenario" ] Exclude: + - spec/features/admin/order_cycles/complex_updating_specific_time_spec.rb + - spec/features/admin/tag_rules_spec.rb - app/models/spree/order/checkout.rb - app/models/spree/payment/processing.rb - app/models/spree/shipment.rb @@ -514,6 +558,27 @@ Metrics/BlockLength: Metrics/CyclomaticComplexity: Max: 6 Exclude: + - app/controllers/admin/resource_controller.rb + - app/controllers/spree/admin/payment_methods_controller.rb + - app/controllers/spree/admin/payments_controller.rb + - app/controllers/spree/admin/products_controller.rb + - app/controllers/spree/admin/users_controller.rb + - app/models/product_import/entry_validator.rb + - app/models/spree/order_inventory.rb + - app/models/spree/order.rb + - app/models/spree/shipment.rb + - app/models/spree/tax_rate.rb + - app/models/spree/variant.rb + - engines/order_management/app/services/order_management/reports/enterprise_fee_summary/parameters.rb + - lib/active_merchant/billing/gateways/stripe_decorator.rb + - lib/open_food_network/group_buy_report.rb + - lib/open_food_network/order_cycle_form_applicator.rb + - lib/open_food_network/order_cycle_permissions.rb + - lib/open_food_network/payments_report.rb + - lib/spree/core/controller_helpers/common.rb + - lib/stripe/authorize_response_patcher.rb + - lib/stripe/credit_card_clone_destroyer.rb + - spec/support/i18n_translations_checker.rb - app/controllers/admin/enterprise_fees_controller.rb - app/controllers/admin/enterprises_controller.rb - app/controllers/spree/admin/taxons_controller.rb @@ -552,6 +617,18 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Max: 7 Exclude: + - app/controllers/spree/admin/payment_methods_controller.rb + - app/controllers/spree/admin/payments_controller.rb + - app/controllers/spree/admin/users_controller.rb + - app/models/product_import/entry_validator.rb + - app/models/spree/order_inventory.rb + - app/models/spree/shipment.rb + - app/models/spree/variant.rb + - lib/active_merchant/billing/gateways/stripe_decorator.rb + - lib/open_food_network/group_buy_report.rb + - lib/open_food_network/order_cycle_form_applicator.rb + - lib/open_food_network/order_cycle_permissions.rb + - lib/open_food_network/payments_report.rb - app/controllers/admin/enterprises_controller.rb - app/controllers/api/variants_controller.rb - app/controllers/spree/admin/taxons_controller.rb @@ -702,10 +779,18 @@ Metrics/MethodLength: - spec/features/consumer/shopping/variant_overrides_spec.rb - spec/models/product_importer_spec.rb - spec/support/i18n_translations_checker.rb + - app/controllers/admin/bulk_line_items_controller.rb + - app/controllers/spree/paypal_controller.rb + - app/jobs/subscription_placement_job.rb + - app/models/spree/gateway/pay_pal_express.rb Metrics/ClassLength: Max: 100 Exclude: + - app/controllers/admin/customers_controller.rb + - app/controllers/spree/admin/payments_controller.rb + - app/controllers/spree/paypal_controller.rb + - engines/order_management/app/services/order_management/order/updater.rb - app/controllers/admin/enterprises_controller.rb - app/controllers/admin/order_cycles_controller.rb - app/controllers/admin/resource_controller.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cd62dcf638..768ce4363e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,16 +1,227 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 1400` -# on 2020-12-23 22:07:55 +0000 using RuboCop version 0.81.0. +# on 2021-03-25 06:59:27 UTC using RuboCop version 1.12.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 # versions of RuboCop, may require this file to be generated again. +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 4 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'engines/catalog/catalog.gemspec' + - 'engines/dfc_provider/dfc_provider.gemspec' + - 'engines/order_management/order_management.gemspec' + - 'engines/web/web.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Exclude: + - 'spec/features/admin/order_cycles/simple_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: start_of_line, begin +Layout/BeginEndAlignment: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/spree/admin/reports_controller.rb' + - 'app/jobs/job_logger.rb' + - 'app/models/spree/address.rb' + - 'app/models/spree/credit_card.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'spec/features/admin/order_cycles/complex_creating_specific_time_spec.rb' + - 'spec/features/admin/order_cycles/simple_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/CommentIndentation: + Exclude: + - 'spec/features/admin/order_cycles/simple_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'spec/features/admin/configuration/tax_rates_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'app/controllers/api/enterprise_attachment_controller.rb' + - 'spec/controllers/spree/admin/base_controller_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'spec/controllers/spree/admin/reports_controller_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'app/models/spree/shipment.rb' + - 'lib/open_food_network/customers_report.rb' + - 'lib/open_food_network/packing_report.rb' + - 'lib/open_food_network/payments_report.rb' + - 'lib/open_food_network/users_and_enterprises_report.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'spec/features/admin/payment_method_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + Exclude: + - 'spec/lib/open_food_network/order_cycle_management_report_spec.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'app/controllers/admin/order_cycles_controller.rb' + - 'spec/features/admin/adjustments_spec.rb' + - 'spec/models/spree/adjustment_spec.rb' + - 'spec/models/spree/order_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'spec/features/admin/order_cycles/complex_creating_specific_time_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/MultilineBlockLayout: + Exclude: + - 'spec/controllers/spree/orders_controller_spec.rb' + - 'spec/services/process_payment_intent_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'spec/controllers/spree/orders_controller_spec.rb' + - 'spec/services/process_payment_intent_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/RescueEnsureAlignment: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/spree/admin/reports_controller.rb' + - 'app/models/spree/address.rb' + - 'app/models/spree/credit_card.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAroundMethodCallOperator: + Exclude: + - 'spec/controllers/api/orders_controller_spec.rb' + - 'spec/controllers/api/shipments_controller_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'spec/controllers/spree/admin/reports_controller_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'spec/services/embedded_page_service_spec.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'spec/features/admin/order_cycles/simple_spec.rb' + - 'spec/features/consumer/shopping/unit_price_spec.rb' + - 'spec/support/features/datepicker_helper.rb' + - 'spec/support/request/web_helper.rb' + - 'spec/views/spree/orders/edit.html.haml_spec.rb' + +# Offense count: 15 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'lib/tasks/users.rake' + - 'spec/controllers/spree/admin/base_controller_spec.rb' + - 'spec/helpers/serializer_helper_spec.rb' + - 'spec/lib/open_food_network/reports/line_items_spec.rb' + - 'spec/models/spree/ability_spec.rb' + - 'spec/models/spree/gateway_spec.rb' + - 'spec/models/spree/preferences/configuration_spec.rb' + - 'spec/models/spree/preferences/preferable_spec.rb' + - 'spec/validators/date_time_string_validator_spec.rb' + - 'spec/validators/integer_array_validator_spec.rb' + # Offense count: 2 Lint/DuplicateMethods: Exclude: - 'lib/discourse/single_sign_on.rb' +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/EmptyFile: + Exclude: + - 'spec/lib/open_food_network/enterprise_injection_data_spec.rb' + +# Offense count: 2 +Lint/FloatComparison: + Exclude: + - 'app/models/product_import/entry_validator.rb' + - 'app/models/spree/gateway/pay_pal_express.rb' + # Offense count: 5 Lint/IneffectiveAccessModifier: Exclude: @@ -18,13 +229,41 @@ Lint/IneffectiveAccessModifier: - 'app/models/spree/user.rb' - 'app/services/mail_configuration.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'app/models/spree/payment.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - '.simplecov' + # Offense count: 2 +# Cop supports --auto-correct. # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'app/models/column_preference.rb' - 'app/services/mail_configuration.rb' +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowComments. +Lint/UselessMethodDefinition: + Exclude: + - 'app/controllers/spree/user_registrations_controller.rb' + - 'app/models/spree/gateway.rb' + +# Offense count: 2 +# Configuration parameters: Max, CountKeywordArgs. +Metrics/ParameterLists: + MaxOptionalParameters: 4 + # Offense count: 10 Naming/AccessorMethodName: Exclude: @@ -51,7 +290,7 @@ Naming/MemoizedInstanceVariableName: - 'app/mailers/producer_mailer.rb' - 'lib/open_food_network/address_finder.rb' -# Offense count: 25 +# Offense count: 23 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ # ForbiddenPrefixes: is_, has_, have_ @@ -59,7 +298,6 @@ Naming/MemoizedInstanceVariableName: # MethodDefinitionMacros: define_method, define_singleton_method Naming/PredicateName: Exclude: - - 'spec/**/*' - 'app/models/enterprise.rb' - 'app/models/enterprise_relationship.rb' - 'app/models/order_cycle.rb' @@ -79,17 +317,28 @@ Naming/PredicateName: - 'lib/open_food_network/packing_report.rb' - 'lib/tasks/data.rake' -# Offense count: 2 -# Configuration parameters: EnforcedStyle. +# Offense count: 30 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. # SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 Naming/VariableNumber: Exclude: + - 'app/controllers/spree/orders_controller.rb' + - 'app/models/content_configuration.rb' + - 'app/models/preference_sections/main_links_section.rb' + - 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb' + - 'lib/spree/core/controller_helpers/common.rb' + - 'spec/controllers/spree/admin/search_controller_spec.rb' - 'spec/factories/stock_location_factory.rb' + - 'spec/features/admin/reports_spec.rb' + - 'spec/models/spree/stock_item_spec.rb' + - 'spec/requests/api/orders_spec.rb' -# Offense count: 8 +# Offense count: 9 # Cop supports --auto-correct. Rails/ActiveRecordAliases: Exclude: + - 'app/models/spree/gateway/pay_pal_express.rb' - 'spec/controllers/line_items_controller_spec.rb' - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/features/admin/subscriptions_spec.rb' @@ -102,6 +351,109 @@ Rails/ApplicationController: Exclude: - 'engines/dfc_provider/app/controllers/dfc_provider/api/base_controller.rb' +# Offense count: 6 +# Cop supports --auto-correct. +Rails/ApplicationJob: + Exclude: + - 'app/jobs/bulk_invoice_job.rb' + - 'app/jobs/confirm_order_job.rb' + - 'app/jobs/heartbeat_job.rb' + - 'app/jobs/order_cycle_notification_job.rb' + - 'app/jobs/subscription_confirm_job.rb' + - 'app/jobs/subscription_placement_job.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/ApplicationMailer: + Exclude: + - 'app/mailers/spree/base_mailer.rb' + +# Offense count: 73 +# Cop supports --auto-correct. +Rails/ApplicationRecord: + Exclude: + - 'app/models/adjustment_metadata.rb' + - 'app/models/column_preference.rb' + - 'app/models/coordinator_fee.rb' + - 'app/models/customer.rb' + - 'app/models/distributor_shipping_method.rb' + - 'app/models/enterprise.rb' + - 'app/models/enterprise_fee.rb' + - 'app/models/enterprise_group.rb' + - 'app/models/enterprise_relationship.rb' + - 'app/models/enterprise_relationship_permission.rb' + - 'app/models/enterprise_role.rb' + - 'app/models/exchange.rb' + - 'app/models/exchange_fee.rb' + - 'app/models/exchange_variant.rb' + - 'app/models/inventory_item.rb' + - 'app/models/order_cycle.rb' + - 'app/models/order_cycle_schedule.rb' + - 'app/models/producer_property.rb' + - 'app/models/proxy_order.rb' + - 'app/models/schedule.rb' + - 'app/models/spree/address.rb' + - 'app/models/spree/adjustment.rb' + - 'app/models/spree/asset.rb' + - 'app/models/spree/calculator.rb' + - 'app/models/spree/classification.rb' + - 'app/models/spree/country.rb' + - 'app/models/spree/credit_card.rb' + - 'app/models/spree/inventory_unit.rb' + - 'app/models/spree/line_item.rb' + - 'app/models/spree/log_entry.rb' + - 'app/models/spree/option_type.rb' + - 'app/models/spree/option_value.rb' + - 'app/models/spree/option_values_line_item.rb' + - 'app/models/spree/order.rb' + - 'app/models/spree/order/checkout.rb' + - 'app/models/spree/payment.rb' + - 'app/models/spree/payment/processing.rb' + - 'app/models/spree/payment_method.rb' + - 'app/models/spree/paypal_express_checkout.rb' + - 'app/models/spree/preference.rb' + - 'app/models/spree/price.rb' + - 'app/models/spree/product.rb' + - 'app/models/spree/product_option_type.rb' + - 'app/models/spree/product_property.rb' + - 'app/models/spree/property.rb' + - 'app/models/spree/return_authorization.rb' + - 'app/models/spree/role.rb' + - 'app/models/spree/shipment.rb' + - 'app/models/spree/shipping_category.rb' + - 'app/models/spree/shipping_method.rb' + - 'app/models/spree/shipping_method_category.rb' + - 'app/models/spree/shipping_rate.rb' + - 'app/models/spree/state.rb' + - 'app/models/spree/state_change.rb' + - 'app/models/spree/stock_item.rb' + - 'app/models/spree/stock_location.rb' + - 'app/models/spree/stock_movement.rb' + - 'app/models/spree/tax_category.rb' + - 'app/models/spree/tax_rate.rb' + - 'app/models/spree/taxon.rb' + - 'app/models/spree/taxonomy.rb' + - 'app/models/spree/tokenized_permission.rb' + - 'app/models/spree/user.rb' + - 'app/models/spree/variant.rb' + - 'app/models/spree/zone.rb' + - 'app/models/spree/zone_member.rb' + - 'app/models/stripe_account.rb' + - 'app/models/subscription.rb' + - 'app/models/subscription_line_item.rb' + - 'app/models/tag_rule.rb' + - 'app/models/variant_override.rb' + - 'lib/tasks/data/remove_transient_data.rb' + - 'spec/models/spree/preferences/preferable_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'app/services/content_sanitizer.rb' + - 'lib/stripe/authorize_response_patcher.rb' + # Offense count: 3 # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -147,14 +499,6 @@ Rails/FindBy: - 'app/models/product_import/spreadsheet_data.rb' - 'app/models/spree/user.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/FindEach: - Exclude: - - 'app/models/spree/shipment.rb' - # Offense count: 11 # Configuration parameters: Include. # Include: app/models/**/*.rb @@ -189,20 +533,19 @@ Rails/HasManyOrHasOneDependent: - 'app/models/spree/shipment.rb' - 'app/models/spree/shipping_category.rb' - 'app/models/spree/shipping_method.rb' + - 'app/models/spree/stock_item.rb' - 'app/models/spree/taxonomy.rb' - 'app/models/spree/user.rb' - 'app/models/spree/variant.rb' - 'app/models/subscription.rb' -# Offense count: 84 +# Offense count: 58 # Configuration parameters: Include. # Include: app/helpers/**/*.rb Rails/HelperInstanceVariable: Exclude: - 'app/helpers/admin/injection_helper.rb' - - 'app/helpers/angular_form_builder.rb' - 'app/helpers/application_helper.rb' - - 'app/helpers/enterprises_helper.rb' - 'app/helpers/injection_helper.rb' - 'app/helpers/order_cycles_helper.rb' - 'app/helpers/shared_helper.rb' @@ -210,7 +553,31 @@ Rails/HelperInstanceVariable: - 'app/helpers/spree/admin/orders_helper.rb' - 'app/helpers/spree/orders_helper.rb' -# Offense count: 33 +# Offense count: 38 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/InverseOf: + Exclude: + - 'app/models/concerns/line_item_based_adjustment_handling.rb' + - 'app/models/customer.rb' + - 'app/models/enterprise.rb' + - 'app/models/enterprise_fee.rb' + - 'app/models/order_cycle.rb' + - 'app/models/spree/adjustment.rb' + - 'app/models/spree/country.rb' + - 'app/models/spree/credit_card.rb' + - 'app/models/spree/line_item.rb' + - 'app/models/spree/option_type.rb' + - 'app/models/spree/order.rb' + - 'app/models/spree/payment.rb' + - 'app/models/spree/product.rb' + - 'app/models/spree/shipment.rb' + - 'app/models/spree/taxonomy.rb' + - 'app/models/spree/user.rb' + - 'app/models/spree/variant.rb' + - 'app/models/subscription.rb' + +# Offense count: 35 # Configuration parameters: Include. # Include: app/controllers/**/*.rb Rails/LexicallyScopedActionFilter: @@ -234,7 +601,7 @@ Rails/LexicallyScopedActionFilter: - 'app/controllers/spree/users_controller.rb' - 'app/controllers/user_passwords_controller.rb' -# Offense count: 14 +# Offense count: 13 Rails/OutputSafety: Exclude: - 'app/controllers/spree/admin/reports_controller.rb' @@ -246,29 +613,45 @@ Rails/OutputSafety: - 'app/helpers/spree/reports_helper.rb' - 'app/serializers/api/product_serializer.rb' - 'lib/spree/money.rb' - - 'lib/spree/money_decorator.rb' - 'spec/features/admin/order_print_ticket_spec.rb' # Offense count: 2 +# Cop supports --auto-correct. +Rails/PluralizationGrammar: + Exclude: + - 'spec/queries/complete_orders_with_balance_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: Exclude: - - 'lib/capistrano/tasks/**/*.rake' - 'lib/tasks/specs.rake' -# Offense count: 11 +# Offense count: 14 +# Cop supports --auto-correct. +Rails/RedundantForeignKey: + Exclude: + - 'app/models/customer.rb' + - 'app/models/enterprise.rb' + - 'app/models/enterprise_fee.rb' + - 'app/models/enterprise_group.rb' + - 'app/models/spree/order.rb' + - 'app/models/spree/shipping_method.rb' + - 'app/models/spree/user.rb' + - 'app/models/subscription.rb' + +# Offense count: 4 Rails/ReflectionClassName: Exclude: - 'app/models/customer.rb' - - 'app/models/distributor_shipping_method.rb' - 'app/models/enterprise_role.rb' - 'app/models/spree/order.rb' - - 'app/models/subscription.rb' -# Offense count: 252 -# Configuration parameters: Blacklist, Whitelist. -# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters +# Offense count: 284 +# Configuration parameters: ForbiddenMethods, AllowedMethods. +# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all Rails/SkipsModelValidations: Exclude: - 'app/controllers/admin/resource_controller.rb' @@ -276,16 +659,16 @@ Rails/SkipsModelValidations: - 'app/controllers/spree/admin/shipping_methods_controller.rb' - 'app/controllers/spree/admin/taxons_controller.rb' - 'app/controllers/spree/credit_cards_controller.rb' - - 'app/controllers/spree/orders_controller.rb' - 'app/jobs/subscription_confirm_job.rb' - 'app/jobs/subscription_placement_job.rb' + - 'app/models/concerns/line_item_stock_changes.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_relationship.rb' - 'app/models/product_import/inventory_reset_strategy.rb' - 'app/models/proxy_order.rb' - 'app/models/spree/address.rb' - - 'app/models/spree/adjustment.rb' - 'app/models/spree/credit_card.rb' + - 'app/models/spree/gateway/pay_pal_express.rb' - 'app/models/spree/inventory_unit.rb' - 'app/models/spree/order.rb' - 'app/models/spree/payment.rb' @@ -299,13 +682,15 @@ Rails/SkipsModelValidations: - 'app/models/subscription.rb' - 'app/models/variant_override.rb' - 'app/services/order_factory.rb' - - 'engines/order_management/spec/performance/order_management/subscriptions/proxy_order_syncer_spec.rb' + - 'app/services/process_payment_intent.rb' + - 'engines/order_management/app/services/order_management/order/updater.rb' - 'engines/order_management/spec/services/order_management/reports/enterprise_fee_summary/report_service_spec.rb' - 'engines/order_management/spec/services/order_management/subscriptions/stripe_payment_setup_spec.rb' - 'lib/spree/core/calculated_adjustments.rb' - 'lib/tasks/data/anonymize_data.rake' - 'lib/tasks/sample_data/product_factory.rb' - 'lib/tasks/users.rake' + - 'spec/controllers/admin/customers_controller_spec.rb' - 'spec/controllers/admin/subscription_line_items_controller_spec.rb' - 'spec/controllers/admin/variant_overrides_controller_spec.rb' - 'spec/controllers/api/order_cycles_controller_spec.rb' @@ -315,12 +700,13 @@ Rails/SkipsModelValidations: - 'spec/controllers/api/variants_controller_spec.rb' - 'spec/controllers/checkout_controller_spec.rb' - 'spec/controllers/enterprises_controller_spec.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' + - 'spec/controllers/spree/admin/orders/invoices_spec.rb' - 'spec/controllers/spree/admin/overview_controller_spec.rb' - 'spec/controllers/spree/admin/payment_methods_controller_spec.rb' - 'spec/controllers/spree/credit_cards_controller_spec.rb' - 'spec/factories.rb' - 'spec/factories/order_factory.rb' + - 'spec/factories/shipment_factory.rb' - 'spec/features/admin/bulk_order_management_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' - 'spec/features/admin/configuration/tax_rates_spec.rb' @@ -332,6 +718,7 @@ Rails/SkipsModelValidations: - 'spec/features/consumer/shopping/checkout_spec.rb' - 'spec/features/consumer/shopping/products_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' + - 'spec/features/consumer/shopping/unit_price_spec.rb' - 'spec/helpers/enterprises_helper_spec.rb' - 'spec/helpers/order_cycles_helper_spec.rb' - 'spec/jobs/subscription_placement_job_spec.rb' @@ -341,6 +728,7 @@ Rails/SkipsModelValidations: - 'spec/lib/open_food_network/products_and_inventory_report_spec.rb' - 'spec/lib/open_food_network/scope_variant_to_hub_spec.rb' - 'spec/lib/stripe/credit_card_cloner_spec.rb' + - 'spec/lib/tasks/data/remove_transient_data_spec.rb' - 'spec/models/concerns/variant_stock_spec.rb' - 'spec/models/enterprise_relationship_spec.rb' - 'spec/models/exchange_spec.rb' @@ -352,6 +740,8 @@ Rails/SkipsModelValidations: - 'spec/models/spree/tax_category_spec.rb' - 'spec/models/spree/variant_spec.rb' - 'spec/models/tag_rule/discount_order_spec.rb' + - 'spec/queries/customers_with_balance_spec.rb' + - 'spec/queries/outstanding_balance_spec.rb' - 'spec/serializers/api/admin/subscription_line_item_serializer_spec.rb' - 'spec/services/cache_service_spec.rb' - 'spec/services/order_cart_reset_spec.rb' @@ -359,11 +749,24 @@ Rails/SkipsModelValidations: - 'spec/services/order_cycle_distributed_products_spec.rb' - 'spec/services/order_factory_spec.rb' - 'spec/services/order_syncer_spec.rb' + - 'spec/services/process_payment_intent_spec.rb' - 'spec/services/product_tag_rules_filterer_spec.rb' - 'spec/services/products_renderer_spec.rb' - 'spec/support/request/shop_workflow.rb' - 'spec/views/spree/shared/_order_details.html.haml_spec.rb' +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'app/models/spree/gateway/pay_pal_express.rb' + - 'spec/controllers/spree/credit_cards_controller_spec.rb' + - 'spec/features/admin/order_cycles/complex_creating_specific_time_spec.rb' + - 'spec/features/admin/order_cycles/simple_spec.rb' + - 'spec/services/customer_order_cancellation_spec.rb' + # Offense count: 5 # Configuration parameters: Include. # Include: app/models/**/*.rb @@ -375,23 +778,50 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/spree/tax_category.rb' - 'app/models/spree/zone.rb' -# Offense count: 2 +# Offense count: 3 # Configuration parameters: Environments. # Environments: development, test, production Rails/UnknownEnv: Exclude: + - 'app/controllers/spree/admin/payment_methods_controller.rb' - 'app/models/spree/app_configuration.rb' - 'lib/spree/core/controller_helpers/ssl.rb' +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'app/controllers/admin/resource_controller.rb' + - 'app/models/customer.rb' + - 'app/models/product_import/spreadsheet_entry.rb' + - 'app/models/spree/line_item.rb' + - 'app/services/action_callbacks.rb' + - 'app/services/cart_service.rb' + - 'lib/discourse/single_sign_on.rb' + # Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowOnConstant. Style/CaseEquality: Exclude: - 'app/helpers/angular_form_helper.rb' - 'spec/models/spree/payment_spec.rb' -# Offense count: 29 +# Offense count: 5 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +Style/CaseLikeIf: + Exclude: + - 'app/controllers/admin/order_cycles_controller.rb' + - 'app/controllers/spree/orders_controller.rb' + - 'app/models/calculator/weight.rb' + - 'app/models/spree/payment/processing.rb' + - 'lib/active_merchant/billing/gateways/stripe_payment_intents.rb' + +# Offense count: 26 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: @@ -420,26 +850,53 @@ Style/ClassAndModuleChildren: - 'spec/controllers/spree/admin/base_controller_spec.rb' - 'spec/models/spree/payment_method_spec.rb' +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'app/controllers/spree/admin/payments_controller.rb' + - 'app/models/tag_rule/discount_order.rb' + - 'spec/lib/open_food_network/group_buy_report_spec.rb' + - 'spec/support/delayed_job_helper.rb' + # Offense count: 3 Style/ClassVars: Exclude: - 'lib/open_food_network/rack_request_blocker.rb' - 'lib/spree/core/delegate_belongs_to.rb' -# Offense count: 4 -# Configuration parameters: EnforcedStyle. +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'config.ru' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/ExplicitBlockArgument: + Exclude: + - 'app/helpers/groups_helper.rb' + - 'app/services/cache_service.rb' + - 'app/services/current_order_locker.rb' + - 'spec/support/embedded_pages_helper.rb' + - 'spec/support/performance_helper.rb' + - 'spec/support/request/shop_workflow.rb' + +# Offense count: 2 +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: - Exclude: - - 'lib/open_food_network/sales_tax_report.rb' - - 'spec/features/admin/bulk_order_management_spec.rb' + EnforcedStyle: unannotated -# Offense count: 365 +# Offense count: 354 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Exclude: + - '.simplecov' - 'app/controllers/admin/bulk_line_items_controller.rb' - 'app/controllers/admin/column_preferences_controller.rb' - 'app/controllers/admin/contents_controller.rb' @@ -480,7 +937,6 @@ Style/FrozenStringLiteralComment: - 'app/controllers/api/taxonomies_controller.rb' - 'app/controllers/api/taxons_controller.rb' - 'app/controllers/api/variants_controller.rb' - - 'app/controllers/base_controller.rb' - 'app/controllers/cart_controller.rb' - 'app/controllers/discourse_sso_controller.rb' - 'app/controllers/enterprises_controller.rb' @@ -522,7 +978,6 @@ Style/FrozenStringLiteralComment: - 'app/controllers/spree/admin/users_controller.rb' - 'app/controllers/spree/admin/variants_controller.rb' - 'app/controllers/spree/admin/zones_controller.rb' - - 'app/controllers/spree/credit_cards_controller.rb' - 'app/controllers/spree/orders_controller.rb' - 'app/controllers/spree/users_controller.rb' - 'app/controllers/stripe/callbacks_controller.rb' @@ -561,8 +1016,6 @@ Style/FrozenStringLiteralComment: - 'app/helpers/spree/orders_helper.rb' - 'app/helpers/spree/reports_helper.rb' - 'app/helpers/spree_currency_helper.rb' - - 'app/jobs/heartbeat_job.rb' - - 'app/jobs/manager_invitation_job.rb' - 'app/jobs/subscription_confirm_job.rb' - 'app/jobs/subscription_placement_job.rb' - 'app/mailers/enterprise_mailer.rb' @@ -624,7 +1077,6 @@ Style/FrozenStringLiteralComment: - 'app/models/tag_rule/filter_payment_methods.rb' - 'app/models/tag_rule/filter_products.rb' - 'app/models/tag_rule/filter_shipping_methods.rb' - - 'app/models/variant_override.rb' - 'app/serializers/api/address_serializer.rb' - 'app/serializers/api/adjustment_serializer.rb' - 'app/serializers/api/cached_enterprise_serializer.rb' @@ -645,7 +1097,6 @@ Style/FrozenStringLiteralComment: - 'app/serializers/api/order_cycle_serializer.rb' - 'app/serializers/api/order_detailed_serializer.rb' - 'app/serializers/api/order_serializer.rb' - - 'app/serializers/api/orders_by_distributor_serializer.rb' - 'app/serializers/api/payment_method_serializer.rb' - 'app/serializers/api/payment_serializer.rb' - 'app/serializers/api/product_serializer.rb' @@ -750,7 +1201,6 @@ Style/FrozenStringLiteralComment: - 'lib/open_food_network/orders_and_fulfillments_report/supplier_totals_report.rb' - 'lib/open_food_network/packing_report.rb' - 'lib/open_food_network/paperclippable.rb' - - 'lib/open_food_network/payments_report.rb' - 'lib/open_food_network/permissions.rb' - 'lib/open_food_network/products_and_inventory_report.rb' - 'lib/open_food_network/products_and_inventory_report_base.rb' @@ -768,9 +1218,7 @@ Style/FrozenStringLiteralComment: - 'lib/open_food_network/user_balance_calculator.rb' - 'lib/open_food_network/users_and_enterprises_report.rb' - 'lib/open_food_network/xero_invoices_report.rb' - - 'lib/spree/api/controller_setup.rb' - 'lib/spree/authentication_helpers.rb' - - 'lib/spree/money_decorator.rb' - 'lib/stripe/account_connector.rb' - 'lib/stripe/profile_storer.rb' - 'lib/stripe/webhook_handler.rb' @@ -796,8 +1244,24 @@ Style/FrozenStringLiteralComment: - 'lib/tasks/sample_data/user_factory.rb' - 'lib/tasks/specs.rake' - 'lib/tasks/users.rake' + - 'spec/features/consumer/shopping/unit_price_spec.rb' + - 'spec/helpers/terms_and_conditions_helper_spec.rb' + - 'spec/initializers/feature_toggles_spec.rb' + - 'spec/lib/open_food_network/reports/line_items_spec.rb' + - 'spec/models/concerns/balance_spec.rb' + - 'spec/services/order_data_masker_spec.rb' -# Offense count: 39 +# Offense count: 6 +# Cop supports --auto-correct. +Style/GlobalStdStream: + Exclude: + - 'lib/tasks/data.rake' + - 'lib/tasks/missing_payments.rake' + - 'lib/tasks/sample_data/logging.rb' + - 'lib/tasks/subscriptions/debug.rake' + - 'lib/tasks/subscriptions/test.rake' + +# Offense count: 38 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -808,7 +1272,6 @@ Style/GuardClause: - 'app/controllers/application_controller.rb' - 'app/controllers/home_controller.rb' - 'app/controllers/spree/orders_controller.rb' - - 'app/controllers/spree/paypal_controller_decorator.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_group.rb' - 'app/models/producer_property.rb' @@ -823,6 +1286,39 @@ Style/GuardClause: - 'spec/support/request/distribution_helper.rb' - 'spec/support/request/shop_workflow.rb' +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces +Style/HashAsLastArrayItem: + Exclude: + - 'app/controllers/admin/enterprises_controller.rb' + - 'app/controllers/admin/subscriptions_controller.rb' + - 'app/services/exchange_products_renderer.rb' + - 'app/services/permitted_attributes/checkout.rb' + - 'app/services/permitted_attributes/order_cycle.rb' + - 'app/services/permitted_attributes/product.rb' + - 'lib/open_food_network/orders_and_fulfillments_report/distributor_totals_by_supplier_report.rb' + - 'lib/open_food_network/xero_invoices_report.rb' + +# Offense count: 1 +# Configuration parameters: MinBranchesCount. +Style/HashLikeCase: + Exclude: + - 'app/models/enterprise.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'spec/features/admin/order_cycles/simple_spec.rb' + - 'spec/features/consumer/account/cards_spec.rb' + - 'spec/features/consumer/account/payments_spec.rb' + - 'spec/features/consumer/account/settings_spec.rb' + - 'spec/features/consumer/account_spec.rb' + # Offense count: 3 Style/MissingRespondToMissing: Exclude: @@ -836,13 +1332,12 @@ Style/MixinUsage: - 'lib/open_food_network/orders_and_fulfillments_report.rb' - 'spec/lib/open_food_network/packing_report_spec.rb' -# Offense count: 42 +# Offense count: 41 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# Configuration parameters: EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - - 'spec/**/*' - 'app/controllers/spree/admin/payment_methods_controller.rb' - 'app/controllers/spree/orders_controller.rb' - 'app/helpers/checkout_helper.rb' @@ -864,12 +1359,103 @@ Style/NumericPredicate: - 'lib/open_food_network/rack_request_blocker.rb' - 'lib/open_food_network/sales_tax_report.rb' - 'lib/open_food_network/xero_invoices_report.rb' - - 'lib/spree/money_decorator.rb' - 'lib/tasks/sample_data.rake' -# Offense count: 243 +# Offense count: 26 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/controllers/admin/subscriptions_controller.rb' + - 'app/mailers/spree/order_mailer.rb' + - 'app/mailers/spree/shipment_mailer.rb' + - 'app/models/enterprise_relationship.rb' + - 'app/models/product_import/entry_processor.rb' + - 'app/models/spree/preferences/file_configuration.rb' + - 'app/models/spree/shipment.rb' + - 'app/services/cart_service.rb' + - 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb' + - 'engines/order_management/app/services/order_management/stock/estimator.rb' + - 'lib/open_food_network/customers_report.rb' + - 'lib/open_food_network/order_and_distributor_report.rb' + - 'lib/open_food_network/order_cycle_management_report.rb' + - 'lib/open_food_network/orders_and_fulfillments_report.rb' + - 'lib/open_food_network/packing_report.rb' + - 'lib/open_food_network/payments_report.rb' + - 'lib/open_food_network/products_and_inventory_report_base.rb' + - 'lib/open_food_network/users_and_enterprises_report.rb' + - 'lib/open_food_network/xero_invoices_report.rb' + - 'lib/spree/core/calculated_adjustments.rb' + - 'lib/spree/core/controller_helpers/order.rb' + - 'lib/spree/core/delegate_belongs_to.rb' + - 'spec/support/request/web_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantAssignment: + Exclude: + - 'app/models/spree/payment.rb' + - 'app/models/spree/taxon.rb' + - 'lib/open_food_network/order_grouper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/open_food_network/enterprise_injection_data.rb' + - 'lib/open_food_network/order_cycle_permissions.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantFileExtensionInRequire: + Exclude: + - 'engines/catalog/spec/spec_helper.rb' + - 'engines/dfc_provider/spec/spec_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantInterpolation: + Exclude: + - 'spec/initializers/feature_toggles_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantRegexpCharacterClass: + Exclude: + - 'app/models/spree/order.rb' + - 'lib/stripe/authorize_response_patcher.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Exclude: + - 'app/models/spree/order.rb' + - 'engines/web/config/routes.rb' + - 'lib/spree/localized_number.rb' + - 'lib/stripe/authorize_response_patcher.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'spec/support/features/datepicker_helper.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'spec/features/consumer/account/cards_spec.rb' + - 'spec/features/consumer/account/payments_spec.rb' + - 'spec/features/consumer/account/settings_spec.rb' + - 'spec/features/consumer/account_spec.rb' + +# Offense count: 240 Style/Send: Exclude: + - 'engines/order_management/spec/services/order_management/reports/bulk_coop/bulk_coop_report_spec.rb' - 'spec/controllers/admin/subscriptions_controller_spec.rb' - 'spec/controllers/checkout_controller_spec.rb' - 'spec/controllers/spree/admin/base_controller_spec.rb' @@ -907,17 +1493,90 @@ Style/Send: - 'spec/services/variant_units/option_value_namer_spec.rb' - 'spec/spec_helper.rb' - 'spec/support/localized_number_helper.rb' - - 'spec/support/matchers/delegate_matchers.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SingleArgumentDig: + Exclude: + - 'app/services/checkout/form_data_adapter.rb' + - 'lib/active_merchant/billing/gateways/stripe_payment_intents.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'Rakefile' + - 'app/controllers/checkout_controller.rb' + - 'app/models/product_import/spreadsheet_entry.rb' + - 'app/models/spree/address.rb' + - 'app/models/spree/preferences/store.rb' + - 'app/services/order_syncer.rb' + - 'app/services/order_workflow.rb' + - 'lib/spree/core/controller_helpers/order.rb' + - 'spec/support/matchers/select2_matchers.rb' + +# Offense count: 45 +# Cop supports --auto-correct. +Style/StringConcatenation: + Exclude: + - 'app/controllers/admin/stripe_connect_settings_controller.rb' + - 'app/helpers/discourse_helper.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/line_item.rb' + - 'app/models/spree/payment_method.rb' + - 'app/models/spree/tax_rate.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' + - 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb' + - 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb' + - 'lib/spree/api/controller_setup.rb' + - 'lib/spree/core/environment_extension.rb' + - 'spec/controllers/user_confirmations_controller_spec.rb' + - 'spec/features/admin/bulk_order_management_spec.rb' + - 'spec/features/admin/products_spec.rb' + - 'spec/features/consumer/account_spec.rb' + - 'spec/features/consumer/authentication_spec.rb' + - 'spec/features/consumer/shopping/shopping_spec.rb' + - 'spec/lib/open_food_network/order_grouper_spec.rb' + - 'spec/models/spree/line_item_spec.rb' + - 'spec/models/spree/product_spec.rb' + - 'spec/models/spree/variant_spec.rb' + - 'spec/requests/embedded_shopfronts_headers_spec.rb' + - 'spec/services/embedded_page_service_spec.rb' + - 'spec/support/api_helper.rb' + - 'spec/support/features/datepicker_helper.rb' # Offense count: 1 +# Cop supports --auto-correct. Style/StructInheritance: Exclude: - 'lib/open_food_network/enterprise_fee_applicator.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. # IgnoredMethods: respond_to, define_method Style/SymbolProc: Exclude: - 'app/models/spree/preferences/preferable.rb' + +# Offense count: 19 +# Cop supports --auto-correct. +Style/WhileUntilModifier: + Exclude: + - 'spec/controllers/admin/subscriptions_controller_spec.rb' + - 'spec/controllers/line_items_controller_spec.rb' + - 'spec/controllers/spree/admin/orders_controller_spec.rb' + - 'spec/controllers/spree/orders_controller_spec.rb' + - 'spec/factories/order_factory.rb' + - 'spec/features/admin/payments_stripe_spec.rb' + - 'spec/jobs/subscription_placement_job_spec.rb' + - 'spec/models/proxy_order_spec.rb' + - 'spec/models/spree/line_item_spec.rb' From ffb4ba5ef504b0f623931c5dd2c5e3f2f29b8647 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 18:07:11 +1100 Subject: [PATCH 7/8] Style numeric predicate use with Rubocop --- spec/factories/product_factory.rb | 2 +- spec/factories/variant_factory.rb | 2 +- spec/features/admin/order_print_ticket_spec.rb | 2 +- spec/models/spree/adjustment_spec.rb | 2 +- spec/performance/injection_helper_spec.rb | 2 +- spec/support/request/ui_component_helper.rb | 2 +- spec/support/request/web_helper.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index bfe9791ccd..aefd7ba399 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -22,7 +22,7 @@ FactoryBot.define do shipping_category { DefaultShippingCategory.find_or_create } # ensure stock item will be created for this products master - before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 } + before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? } factory :product do transient do diff --git a/spec/factories/variant_factory.rb b/spec/factories/variant_factory.rb index d1586dc19a..61badeed3e 100644 --- a/spec/factories/variant_factory.rb +++ b/spec/factories/variant_factory.rb @@ -15,7 +15,7 @@ FactoryBot.define do option_values { [create(:option_value)] } # ensure stock item will be created for this variant - before(:create) { create(:stock_location) if Spree::StockLocation.count == 0 } + before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? } factory :variant do transient do diff --git a/spec/features/admin/order_print_ticket_spec.rb b/spec/features/admin/order_print_ticket_spec.rb index 15fd46692a..9bfddf205d 100644 --- a/spec/features/admin/order_print_ticket_spec.rb +++ b/spec/features/admin/order_print_ticket_spec.rb @@ -75,7 +75,7 @@ feature ' def adjustments_in_print_data checkout_adjustments_for(order, exclude: [:line_item]). - reject { |a| a.amount == 0 }. + reject { |a| a.amount.zero? }. map do |adjustment| [raw(adjustment.label), display_adjustment_amount(adjustment).format(symbol: false, with_currency: false)] diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index b38666751a..39e48cafc6 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -186,7 +186,7 @@ module Spree end it "has tax included" do - expect(adjustment.amount).to be > 0 + expect(adjustment.amount).to be_positive expect(adjustment.included).to be true end diff --git a/spec/performance/injection_helper_spec.rb b/spec/performance/injection_helper_spec.rb index 9bf1d8e147..1d67842640 100644 --- a/spec/performance/injection_helper_spec.rb +++ b/spec/performance/injection_helper_spec.rb @@ -22,7 +22,7 @@ describe InjectionHelper, type: :helper, performance: true do ActiveRecord::Base.connection.query_cache.clear Rails.cache.delete_matched('api\/cached_enterprise_serializer\/enterprises') result = Benchmark.measure { helper.inject_enterprises } - results << result.total if i > 0 + results << result.total if i.positive? puts result end diff --git a/spec/support/request/ui_component_helper.rb b/spec/support/request/ui_component_helper.rb index 6b85e51768..bfaee94a40 100644 --- a/spec/support/request/ui_component_helper.rb +++ b/spec/support/request/ui_component_helper.rb @@ -78,7 +78,7 @@ module UIComponentHelper def wait_for_ajax counter = 0 - while page.execute_script("return $.active").to_i > 0 + while page.execute_script("return $.active").to_i.positive? counter += 1 sleep(0.1) raise "AJAX request took longer than 5 seconds." if counter >= 50 diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index 334b913d4b..86ba297357 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -157,6 +157,6 @@ module WebHelper end def wait_for_ajax - wait_until { page.evaluate_script("$.active") == 0 } + wait_until { page.evaluate_script("$.active").zero? } end end From 49eaee05a233c35b08fad7c6d26204998241bcbc Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 25 Mar 2021 18:10:01 +1100 Subject: [PATCH 8/8] Deactivate cop Naming/PredicateName It picked up matcher helpers in specs like `have_in_cart` which is a useful name here. --- .rubocop_styleguide.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 7cf8fdf518..57623f0e22 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -219,3 +219,6 @@ Metrics/ParameterLists: Metrics/PerceivedComplexity: Max: 7 + +Naming/PredicateName: + Enabled: false