From 0ac16ce0964cc1379f28804beeed17f8871d6e74 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Mon, 17 Sep 2018 13:00:44 +0200 Subject: [PATCH] Get useful feedback from Rubocop Metrics cops One of the biggest pros of linters like Rubocop is to get valuable feedback to help write better code. The way we have Rubocop configured now we don't prevent new code from adhere improved code quality and this is specially important when touching code that already suffers from complexity. Without all Rubocop's Metrics cops enabled there's no way to get this insights and write better code. This enables them while regenerating the `.rubocop_todo.yml` to hide the current violations. So, next time we touch existing code that we think could be simpler, we should go to `.rubocop_todo.yml` and remove any occurrences of the file in question. This way we could Rubocop's feedback right in the editor. This is tremendously helpful when refactoring. It shows you where to start. --- .codeclimate.yml | 16 +-- .rubocop.yml | 22 ++--- .rubocop_todo.yml | 246 +++++++++++++++++++++++++++------------------- Gemfile.lock | 4 +- 4 files changed, 165 insertions(+), 123 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 9646b677e9a..60c015c60e7 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,7 +2,7 @@ version: "2" plugins: rubocop: enabled: true - channel: "rubocop-0-55" + channel: "rubocop-0-57" scss-lint: enabled: true checks: @@ -19,23 +19,23 @@ checks: argument-count: enabled: false complex-logic: - enabled: true + enabled: false file-lines: - enabled: true + enabled: false method-complexity: - enabled: true + enabled: false method-count: enabled: false method-lines: enabled: false nested-control-flow: - enabled: true + enabled: false return-statements: - enabled: true + enabled: false similar-code: - enabled: true + enabled: false identical-code: - enabled: true + enabled: false exclude_patterns: - "spec/**/*" - "vendor/**/*" diff --git a/.rubocop.yml b/.rubocop.yml index 80d4c1bf7e6..f62c124ea6d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,16 +4,12 @@ inherit_from: AllCops: TargetRubyVersion: 2.1 TargetRailsVersion: 3.2 - Include: - - '**/Rakefile' - - '**/config.ru' Exclude: - 'db/**/*' - 'config/**/*' - 'script/**/*' - 'vendor/**/*' - 'node_modules/**/*' - - !ruby/regexp /old_and_unused\.rb$/ # The parser gem fails to parse this file with out current Ruby version. - 'spec/factories.rb' @@ -174,28 +170,28 @@ Lint/AssignmentInCondition: StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition Metrics/AbcSize: - Enabled: false + Max: 15 Metrics/BlockNesting: - Enabled: false + Max: 3 Metrics/ClassLength: - Enabled: false + Max: 100 Metrics/ModuleLength: - Enabled: false + Max: 100 Metrics/CyclomaticComplexity: - Enabled: false + Max: 6 Metrics/LineLength: - Enabled: false + Max: 80 Metrics/MethodLength: - Enabled: false + Max: 10 Metrics/ParameterLists: - Enabled: false + Max: 5 Metrics/PerceivedComplexity: - Enabled: false + Max: 7 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7798d41309e..378129593e8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 1400` -# on 2018-08-06 18:22:59 +0800 using RuboCop version 0.55.0. +# on 2018-09-19 19:24:45 +0200 using RuboCop version 0.57.2. # 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: 35 +# Offense count: 32 # Cop supports --auto-correct. # Configuration parameters: Include, TreatCommentsAsGroupSeparators. # Include: **/*.gemfile, **/Gemfile, **/gems.rb @@ -14,20 +14,20 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 116 +# Offense count: 115 # Cop supports --auto-correct. Layout/AlignArray: Exclude: - - 'app/controllers/admin/contents_controller.rb' - 'lib/open_food_network/bulk_coop_report.rb' - 'lib/open_food_network/customers_report.rb' - 'lib/open_food_network/order_and_distributor_report.rb' - 'lib/open_food_network/orders_and_fulfillments_report.rb' - 'lib/open_food_network/packing_report.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' + - 'spec/controllers/cart_controller_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' + - 'spec/services/cart_service_spec.rb' -# Offense count: 127 +# Offense count: 121 # Cop supports --auto-correct. # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -35,7 +35,6 @@ Layout/AlignArray: # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit Layout/AlignHash: Exclude: - - 'app/overrides/add_capture_order_shortcut.rb' - 'app/overrides/replace_shipping_address_form_with_distributor_details.rb' - 'lib/open_food_network/bulk_coop_report.rb' - 'lib/open_food_network/orders_and_fulfillments_report.rb' @@ -64,7 +63,6 @@ Layout/AlignHash: # SupportedStyles: with_first_parameter, with_fixed_indentation Layout/AlignParameters: Exclude: - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/helpers/injection_helper.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_group.rb' @@ -77,9 +75,11 @@ Layout/AlignParameters: - 'lib/tasks/dev.rake' - 'spec/controllers/enterprises_controller_spec.rb' - 'spec/controllers/shop_controller_spec.rb' + - 'spec/features/admin/enterprise_fees_spec.rb' - 'spec/features/admin/enterprise_relationships_spec.rb' - 'spec/features/admin/order_cycles_spec.rb' - 'spec/features/consumer/shopping/checkout_spec.rb' + - 'spec/features/consumer/shopping/orders_spec.rb' - 'spec/helpers/enterprises_helper_spec.rb' - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - 'spec/serializers/variant_serializer_spec.rb' @@ -104,9 +104,16 @@ Layout/BlockEndNewline: # Offense count: 1 # Cop supports --auto-correct. +Layout/ClosingHeredocIndentation: + Exclude: + - 'app/models/content_configuration.rb' + +# Offense count: 2 +# Cop supports --auto-correct. Layout/ClosingParenthesisIndentation: Exclude: - - 'spec/features/admin/order_cycles_spec.rb' + - 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb' + - 'spec/serializers/variant_serializer_spec.rb' # Offense count: 8 # Cop supports --auto-correct. @@ -119,7 +126,7 @@ Layout/ElseAlignment: - 'app/serializers/api/admin/order_cycle_serializer.rb' - 'lib/open_food_network/sales_tax_report.rb' -# Offense count: 205 +# Offense count: 201 # Cop supports --auto-correct. Layout/EmptyLines: Exclude: @@ -162,7 +169,6 @@ Layout/EmptyLines: - 'app/models/spree/line_item_decorator.rb' - 'app/models/spree/option_type_decorator.rb' - 'app/models/spree/option_value_decorator.rb' - - 'app/models/spree/order_populator_decorator.rb' - 'app/models/spree/payment_decorator.rb' - 'app/models/spree/preference_decorator.rb' - 'app/models/spree/preferences/file_configuration.rb' @@ -215,6 +221,7 @@ Layout/EmptyLines: - 'spec/features/admin/order_cycles_spec.rb' - 'spec/features/admin/orders_spec.rb' - 'spec/features/admin/payment_method_spec.rb' + - 'spec/features/admin/product_import_spec.rb' - 'spec/features/admin/products_spec.rb' - 'spec/features/admin/reports_spec.rb' - 'spec/features/admin/shipping_methods_spec.rb' @@ -242,7 +249,6 @@ Layout/EmptyLines: - 'spec/models/product_distribution_spec.rb' - 'spec/models/spree/adjustment_spec.rb' - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/order_populator_spec.rb' - 'spec/models/spree/order_spec.rb' - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/shipping_method_spec.rb' @@ -252,6 +258,7 @@ Layout/EmptyLines: - 'spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb' - 'spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb' - 'spec/serializers/credit_card_serializer_spec.rb' + - 'spec/services/cart_service_spec.rb' - 'spec/support/delayed_job_helper.rb' - 'spec/support/matchers/table_matchers.rb' @@ -261,7 +268,7 @@ Layout/EmptyLinesAroundArguments: Exclude: - 'spec/archive/features/consumer/checkout_spec.rb' -# Offense count: 64 +# Offense count: 61 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines @@ -281,7 +288,6 @@ Layout/EmptyLinesAroundBlockBody: - 'lib/tasks/users.rake' - 'spec/controllers/admin/order_cycles_controller_spec.rb' - 'spec/controllers/admin/tag_rules_controller_spec.rb' - - 'spec/controllers/cart_controller_spec.rb' - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/controllers/spree/admin/reports_controller_spec.rb' - 'spec/controllers/spree/api/orders_controller_spec.rb' @@ -292,6 +298,7 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/features/admin/orders_spec.rb' - 'spec/features/admin/reports_spec.rb' - 'spec/features/admin/variant_overrides_spec.rb' + - 'spec/features/consumer/cookies_spec.rb' - 'spec/features/consumer/shopping/embedded_groups_spec.rb' - 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' @@ -307,8 +314,8 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/lib/open_food_network/referer_parser_spec.rb' - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - 'spec/models/billable_period_spec.rb' - - 'spec/models/cart_spec.rb' - 'spec/models/product_distribution_spec.rb' + - 'spec/models/product_import/product_list_spec.rb' - 'spec/models/spree/ability_spec.rb' - 'spec/models/spree/product_spec.rb' - 'spec/models/tag_rule/filter_payment_methods_spec.rb' @@ -320,7 +327,7 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/support/matchers/select2_matchers.rb' - 'spec/support/matchers/table_matchers.rb' -# Offense count: 26 +# Offense count: 24 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -330,7 +337,6 @@ Layout/EmptyLinesAroundClassBody: - 'app/controllers/admin/cache_settings_controller.rb' - 'app/controllers/admin/enterprise_fees_controller.rb' - 'app/controllers/admin/inventory_items_controller.rb' - - 'app/controllers/admin/invoice_settings_controller.rb' - 'app/controllers/admin/tag_rules_controller.rb' - 'app/controllers/api/enterprises_controller.rb' - 'app/controllers/application_controller.rb' @@ -362,7 +368,7 @@ Layout/EndAlignment: - 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb' - 'app/serializers/api/admin/order_cycle_serializer.rb' -# Offense count: 48 +# Offense count: 49 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. Layout/ExtraSpacing: @@ -388,6 +394,7 @@ Layout/ExtraSpacing: - 'spec/features/admin/reports_spec.rb' - 'spec/features/consumer/groups_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' + - 'spec/helpers/cookies_policy_helper_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - 'spec/lib/open_food_network/reports/rule_spec.rb' - 'spec/models/enterprise_fee_spec.rb' @@ -405,7 +412,7 @@ Layout/ExtraSpacing: # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses Layout/FirstParameterIndentation: Exclude: - 'spec/controllers/spree/admin/orders/customer_details_controller_spec.rb' @@ -417,7 +424,7 @@ Layout/FirstParameterIndentation: Layout/IndentArray: EnforcedStyle: consistent -# Offense count: 51 +# Offense count: 53 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -437,12 +444,11 @@ Layout/IndentationConsistency: - 'spec/models/spree/line_item_spec.rb' - 'spec/models/spree/product_spec.rb' -# Offense count: 21 +# Offense count: 20 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Exclude: - - 'app/controllers/admin/invoice_settings_controller.rb' - 'app/controllers/admin/order_cycles_controller.rb' - 'app/controllers/api/order_cycles_controller.rb' - 'app/models/spree/line_item_decorator.rb' @@ -460,6 +466,12 @@ Layout/IndentationWidth: - 'spec/models/enterprise_spec.rb' - 'spec/models/spree/calculator/flexi_rate_spec.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Layout/LeadingBlankLines: + Exclude: + - 'lib/tasks/dev.rake' + # Offense count: 46 # Cop supports --auto-correct. Layout/LeadingCommentSpace: @@ -469,7 +481,6 @@ Layout/LeadingCommentSpace: - 'app/models/content_configuration.rb' - 'app/models/spree/inventory_unit_decorator.rb' - 'app/models/spree/taxon_decorator.rb' - - 'app/overrides/add_capture_order_shortcut.rb' - 'app/serializers/api/address_serializer.rb' - 'app/serializers/api/enterprise_serializer.rb' - 'app/serializers/api/product_serializer.rb' @@ -521,7 +532,7 @@ Layout/MultilineHashBraceLayout: - 'lib/spree/product_filters.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line @@ -529,9 +540,9 @@ Layout/MultilineMethodCallBraceLayout: Exclude: - 'app/helpers/spree/orders_helper.rb' - 'app/models/spree/variant_decorator.rb' - - 'app/overrides/add_capture_order_shortcut.rb' - 'lib/open_food_network/products_renderer.rb' - 'spec/features/admin/order_cycles_spec.rb' + - 'spec/features/consumer/shopping/orders_spec.rb' - 'spec/lib/open_food_network/products_and_inventory_report_spec.rb' # Offense count: 4 @@ -543,7 +554,7 @@ Layout/MultilineMethodCallIndentation: - 'spec/lib/open_food_network/cached_products_renderer_spec.rb' - 'spec/serializers/variant_serializer_spec.rb' -# Offense count: 30 +# Offense count: 28 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented @@ -611,7 +622,7 @@ Layout/SpaceAfterSemicolon: Exclude: - 'spec/controllers/spree/admin/base_controller_spec.rb' -# Offense count: 62 +# Offense count: 59 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -672,11 +683,11 @@ Layout/SpaceAroundOperators: - 'lib/spree/product_filters.rb' - 'spec/controllers/admin/enterprises_controller_spec.rb' - 'spec/controllers/cart_controller_spec.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/features/admin/bulk_order_management_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' - 'spec/features/consumer/shopping/checkout_spec.rb' - 'spec/helpers/checkout_helper_spec.rb' + - 'spec/helpers/cookies_policy_helper_spec.rb' - 'spec/helpers/order_cycles_helper_spec.rb' - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' @@ -713,7 +724,7 @@ Layout/SpaceInLambdaLiteral: - 'app/models/spree/product_decorator.rb' - 'app/models/spree/variant_decorator.rb' -# Offense count: 130 +# Offense count: 128 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. # SupportedStyles: space, no_space, compact @@ -728,7 +739,6 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'lib/open_food_network/payments_report.rb' - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/controllers/admin/variant_overrides_controller_spec.rb' - - 'spec/controllers/cart_controller_spec.rb' - 'spec/features/admin/reports_spec.rb' - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' @@ -789,7 +799,7 @@ Layout/SpaceInsideBlockBraces: - 'spec/spec_helper.rb' - 'spec/support/cancan_helper.rb' -# Offense count: 772 +# Offense count: 734 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -797,7 +807,6 @@ Layout/SpaceInsideBlockBraces: Layout/SpaceInsideHashLiteralBraces: Exclude: - 'app/controllers/admin/cache_settings_controller.rb' - - 'app/controllers/admin/contents_controller.rb' - 'app/controllers/admin/enterprise_relationships_controller.rb' - 'app/controllers/admin/enterprise_roles_controller.rb' - 'app/controllers/api/statuses_controller.rb' @@ -805,7 +814,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'app/controllers/spree/admin/line_items_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/admin/injection_helper.rb' - 'app/helpers/angular_form_builder.rb' @@ -822,11 +830,9 @@ Layout/SpaceInsideHashLiteralBraces: - 'app/models/enterprise_relationship.rb' - 'app/models/producer_property.rb' - 'app/models/spree/gateway/stripe_connect.rb' - - 'app/models/spree/order_populator_decorator.rb' - 'app/models/spree/product_decorator.rb' - 'app/models/spree/property_decorator.rb' - 'app/models/spree/shipping_method_decorator.rb' - - 'app/overrides/add_capture_order_shortcut.rb' - 'app/serializers/api/admin/enterprise_fee_serializer.rb' - 'app/serializers/api/admin/order_cycle_serializer.rb' - 'lib/open_food_network/feature_toggle.rb' @@ -886,7 +892,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/models/spree/ability_spec.rb' - 'spec/models/spree/gateway/stripe_connect_spec.rb' - 'spec/models/spree/image_spec.rb' - - 'spec/models/spree/order_populator_spec.rb' - 'spec/models/spree/order_spec.rb' - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/shipping_method_spec.rb' @@ -898,6 +903,7 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/requests/checkout/failed_checkout_spec.rb' - 'spec/requests/checkout/stripe_connect_spec.rb' - 'spec/serializers/enterprise_serializer_spec.rb' + - 'spec/services/cart_service_spec.rb' - 'spec/services/order_syncer_spec.rb' - 'spec/services/subscription_form_spec.rb' - 'spec/spec_helper.rb' @@ -926,17 +932,24 @@ Layout/SpaceInsideStringInterpolation: - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. Layout/Tab: Exclude: - - 'app/controllers/admin/invoice_settings_controller.rb' - 'app/models/spree/line_item_decorator.rb' - 'spec/lib/spree/product_filters_spec.rb' - 'spec/models/spree/line_item_spec.rb' -# Offense count: 60 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'spec/controllers/cart_controller_spec.rb' + +# Offense count: 64 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -952,8 +965,10 @@ Layout/TrailingWhitespace: - 'app/views/json/_producer.rabl' - 'app/views/json/partials/_producer.rabl' - 'spec/controllers/admin/column_preferences_controller_spec.rb' - - 'spec/features/admin/enterprise_user_spec.rb' + - 'spec/features/admin/customers_spec.rb' - 'spec/features/admin/variant_overrides_spec.rb' + - 'spec/features/consumer/cookies_spec.rb' + - 'spec/helpers/cookies_policy_helper_spec.rb' - 'spec/helpers/enterprises_helper_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - 'spec/lib/open_food_network/group_buy_report_spec.rb' @@ -977,7 +992,7 @@ Lint/DuplicateMethods: - 'lib/discourse/single_sign_on.rb' - 'lib/open_food_network/subscription_summary.rb' -# Offense count: 18 +# Offense count: 16 Lint/IneffectiveAccessModifier: Exclude: - 'app/models/column_preference.rb' @@ -1035,7 +1050,7 @@ Lint/UnderscorePrefixedVariableName: Exclude: - 'spec/support/cancan_helper.rb' -# Offense count: 123 +# Offense count: 121 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: @@ -1047,7 +1062,6 @@ Lint/UnusedBlockArgument: - 'app/models/column_preference.rb' - 'app/models/model_set.rb' - 'app/models/spree/order_decorator.rb' - - 'app/models/spree/order_populator_decorator.rb' - 'lib/open_food_network/bulk_coop_report.rb' - 'lib/open_food_network/enterprise_fee_calculator.rb' - 'lib/open_food_network/group_buy_report.rb' @@ -1086,7 +1100,7 @@ Lint/UnusedMethodArgument: - 'lib/open_food_network/paperclippable.rb' - 'lib/open_food_network/rack_request_blocker.rb' -# Offense count: 7 +# Offense count: 6 # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: @@ -1097,14 +1111,13 @@ Lint/UselessAccessModifier: - 'lib/open_food_network/reports/bulk_coop_report.rb' - 'spec/lib/open_food_network/reports/report_spec.rb' -# Offense count: 288 +# Offense count: 246 # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: - 'app/serializers/api/enterprise_serializer.rb' - 'spec/archive/features/consumer/checkout_spec.rb' - 'spec/controllers/api/order_cycles_controller_spec.rb' - - 'spec/controllers/cart_controller_spec.rb' - 'spec/controllers/checkout_controller_spec.rb' - 'spec/controllers/enterprises_controller_spec.rb' - 'spec/controllers/shop_controller_spec.rb' @@ -1113,10 +1126,8 @@ Lint/Void: - 'spec/controllers/spree/admin/variants_controller_spec.rb' - 'spec/controllers/spree/api/products_controller_spec.rb' - 'spec/controllers/spree/api/variants_controller_spec.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/controllers/user_registrations_controller_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' - - 'spec/features/admin/enterprise_fees_spec.rb' - 'spec/features/admin/enterprise_groups_spec.rb' - 'spec/features/admin/enterprises/index_spec.rb' - 'spec/features/admin/enterprises_spec.rb' @@ -1141,14 +1152,12 @@ Lint/Void: - 'spec/lib/open_food_network/reports/report_spec.rb' - 'spec/lib/open_food_network/reports/rule_spec.rb' - 'spec/mailers/order_mailer_spec.rb' - - 'spec/models/cart_spec.rb' - 'spec/models/enterprise_relationship_spec.rb' - 'spec/models/enterprise_spec.rb' - 'spec/models/exchange_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/spree/adjustment_spec.rb' - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/order_populator_spec.rb' - 'spec/models/spree/order_spec.rb' - 'spec/models/spree/payment_method_spec.rb' - 'spec/models/spree/payment_spec.rb' @@ -1158,10 +1167,53 @@ Lint/Void: - 'spec/serializers/enterprise_serializer_spec.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 993 +# Offense count: 195 +Metrics/AbcSize: + Max: 293 + +# Offense count: 1010 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 776 + Max: 787 + +# Offense count: 1 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 4 + +# Offense count: 23 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 331 + +# Offense count: 38 +Metrics/CyclomaticComplexity: + Max: 23 + +# Offense count: 6683 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 623 + +# Offense count: 163 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 95 + +# Offense count: 27 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 633 + +# Offense count: 6 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 8 + +# Offense count: 30 +Metrics/PerceivedComplexity: + Max: 21 # Offense count: 7 Naming/AccessorMethodName: @@ -1176,14 +1228,6 @@ Naming/BinaryOperatorParameterName: Exclude: - 'app/models/exchange.rb' -# Offense count: 2 -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. -# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS -Naming/FileName: - Exclude: - - 'Gemfile' - - 'Guardfile' - # Offense count: 1 # Configuration parameters: Blacklist. # Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) @@ -1224,12 +1268,11 @@ Naming/PredicateName: - 'lib/open_food_network/packing_report.rb' - 'lib/tasks/data.rake' -# Offense count: 14 +# Offense count: 13 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: io, id, to, by, on, in, at Naming/UncommunicativeMethodParamName: Exclude: - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/helpers/admin/injection_helper.rb' - 'app/helpers/spree/admin/base_helper_decorator.rb' - 'app/helpers/spree/base_helper_decorator.rb' @@ -1275,6 +1318,15 @@ Performance/DoubleStartEndWith: Exclude: - 'app/helpers/application_helper.rb' +# Offense count: 4 +# Cop supports --auto-correct. +Performance/InefficientHashSearch: + Exclude: + - 'app/models/spree/payment_method_decorator.rb' + - 'app/models/spree/preferences/file_configuration.rb' + - 'lib/stripe/account_connector.rb' + - 'lib/stripe/webhook_handler.rb' + # Offense count: 3 # Cop supports --auto-correct. Performance/RedundantBlockCall: @@ -1346,6 +1398,8 @@ Rails/Delegate: - 'app/serializers/api/variant_serializer.rb' # Offense count: 8 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments Rails/FilePath: Exclude: - 'lib/tasks/karma.rake' @@ -1377,14 +1431,13 @@ Rails/HasAndBelongsToMany: - 'app/models/spree/line_item_decorator.rb' - 'app/models/spree/payment_method_decorator.rb' -# Offense count: 31 +# Offense count: 29 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/account_invoice.rb' - 'app/models/billable_period.rb' - - 'app/models/cart.rb' - 'app/models/customer.rb' - 'app/models/enterprise.rb' - 'app/models/order_cycle.rb' @@ -1416,6 +1469,7 @@ Rails/HttpStatus: - 'app/controllers/api/customers_controller.rb' - 'app/controllers/api/enterprises_controller.rb' - 'app/controllers/application_controller.rb' + - 'app/controllers/cart_controller.rb' - 'app/controllers/checkout_controller.rb' - 'app/controllers/enterprises_controller.rb' - 'app/controllers/line_items_controller.rb' @@ -1423,7 +1477,6 @@ Rails/HttpStatus: - 'app/controllers/spree/admin/line_items_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/credit_cards_controller.rb' - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/controllers/spree/store_controller_decorator.rb' - 'app/controllers/stripe/callbacks_controller.rb' - 'app/controllers/stripe/webhooks_controller.rb' @@ -1470,7 +1523,7 @@ Rails/ReadWriteAttribute: Exclude: - 'app/models/enterprise.rb' -# Offense count: 47 +# Offense count: 46 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/ScopeArgs: @@ -1501,6 +1554,7 @@ Rails/TimeZone: - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/controllers/api/statuses_controller_spec.rb' - 'spec/jobs/heartbeat_job_spec.rb' + - 'spec/lib/open_food_network/products_cache_refreshment_spec.rb' - 'spec/lib/open_food_network/products_cache_spec.rb' - 'spec/models/enterprise_relationship_spec.rb' - 'spec/models/variant_override_spec.rb' @@ -1557,7 +1611,7 @@ Style/BarePercentLiterals: - 'spec/features/admin/variants_spec.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 210 +# Offense count: 207 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: braces, no_braces, context_dependent @@ -1568,7 +1622,6 @@ Style/BracesAroundHashParameters: - 'app/controllers/checkout_controller.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/helpers/admin/account_helper.rb' - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/angular_form_builder.rb' @@ -1578,7 +1631,6 @@ Style/BracesAroundHashParameters: - 'app/jobs/update_account_invoices.rb' - 'app/jobs/update_billable_periods.rb' - 'app/models/billable_period.rb' - - 'app/models/cart.rb' - 'app/models/exchange.rb' - 'app/models/spree/adjustment_decorator.rb' - 'app/models/spree/line_item_decorator.rb' @@ -1622,11 +1674,11 @@ Style/BracesAroundHashParameters: - 'spec/models/billable_period_spec.rb' - 'spec/models/product_distribution_spec.rb' - 'spec/models/spree/ability_spec.rb' - - 'spec/models/spree/order_populator_spec.rb' - 'spec/models/spree/order_spec.rb' - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/taxon_spec.rb' - 'spec/serializers/admin/customer_serializer_spec.rb' + - 'spec/services/cart_service_spec.rb' - 'spec/spec_helper.rb' - 'spec/support/cancan_helper.rb' - 'spec/support/request/authentication_workflow.rb' @@ -1638,7 +1690,7 @@ Style/CaseEquality: - 'app/helpers/angular_form_helper.rb' - 'spec/models/spree/payment_spec.rb' -# Offense count: 86 +# Offense count: 85 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: nested, compact @@ -1648,7 +1700,6 @@ Style/ClassAndModuleChildren: - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - 'app/controllers/admin/business_model_configuration_controller.rb' - 'app/controllers/admin/cache_settings_controller.rb' - - 'app/controllers/admin/invoice_settings_controller.rb' - 'app/controllers/spree/store_controller_decorator.rb' - 'app/helpers/angular_form_helper.rb' - 'app/models/calculator/flat_percent_per_item.rb' @@ -1751,20 +1802,15 @@ Style/CommentedKeyword: Exclude: - 'app/controllers/application_controller.rb' -# Offense count: 10 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: - 'app/controllers/checkout_controller.rb' - - 'app/controllers/spree/admin/base_controller_decorator.rb' - - 'app/controllers/spree/admin/payment_methods_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/helpers/spree/admin/orders_helper_decorator.rb' - - 'app/models/spree/calculator/per_item_decorator.rb' - 'app/models/spree/line_item_decorator.rb' - - 'app/models/spree/payment_decorator.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' # Offense count: 2 @@ -1817,7 +1863,7 @@ Style/FormatStringToken: - 'lib/open_food_network/sales_tax_report.rb' - 'spec/models/enterprise_spec.rb' -# Offense count: 83 +# Offense count: 79 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -1848,7 +1894,6 @@ Style/GuardClause: - 'app/models/producer_property.rb' - 'app/models/spree/classification_decorator.rb' - 'app/models/spree/order_decorator.rb' - - 'app/models/spree/order_populator_decorator.rb' - 'app/models/spree/preference_decorator.rb' - 'app/models/spree/product_decorator.rb' - 'app/models/spree/user_decorator.rb' @@ -1866,7 +1911,7 @@ Style/GuardClause: - 'spec/support/request/distribution_helper.rb' - 'spec/support/request/shop_workflow.rb' -# Offense count: 968 +# Offense count: 930 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -1881,14 +1926,12 @@ Style/HashSyntax: - 'app/controllers/admin/tag_rules_controller.rb' - 'app/controllers/api/enterprises_controller.rb' - 'app/controllers/checkout_controller.rb' - - 'app/controllers/open_food_network/cart_controller.rb' - 'app/controllers/spree/admin/line_items_controller_decorator.rb' - 'app/controllers/spree/admin/orders_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb' - 'app/controllers/spree/api/products_controller_decorator.rb' - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/controllers/spree/paypal_controller_decorator.rb' - 'app/controllers/spree/store_controller_decorator.rb' - 'app/controllers/user_passwords_controller.rb' @@ -1904,7 +1947,6 @@ Style/HashSyntax: - 'app/mailers/spree/user_mailer_decorator.rb' - 'app/models/billable_period.rb' - 'app/models/calculator/flat_percent_per_item.rb' - - 'app/models/cart.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_fee.rb' - 'app/models/enterprise_group.rb' @@ -1928,12 +1970,10 @@ Style/HashSyntax: - 'app/models/spree/product_set.rb' - 'app/models/spree/taxon_decorator.rb' - 'app/models/spree/user_decorator.rb' - - 'app/overrides/add_capture_order_shortcut.rb' - 'app/overrides/add_distributor_details_js_to_product.rb' - 'app/overrides/add_distributor_details_to_product.rb' - 'app/overrides/add_distributor_to_add_to_cart_form.rb' - 'app/overrides/add_enterprise_fees_to_admin_configurations_menu.rb' - - 'app/overrides/add_orders_admin_sub_menu.rb' - 'app/overrides/add_source_to_product.rb' - 'app/overrides/remove_search_bar.rb' - 'app/overrides/remove_side_bar.rb' @@ -1976,13 +2016,11 @@ Style/HashSyntax: - 'spec/controllers/spree/api/products_controller_spec.rb' - 'spec/controllers/spree/api/variants_controller_spec.rb' - 'spec/controllers/spree/credit_cards_controller_spec.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/controllers/spree/user_sessions_controller_spec.rb' - 'spec/controllers/user_registrations_controller_spec.rb' - 'spec/features/admin/bulk_order_management_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' - 'spec/features/admin/customers_spec.rb' - - 'spec/features/admin/enterprise_fees_spec.rb' - 'spec/features/admin/enterprise_groups_spec.rb' - 'spec/features/admin/enterprises_spec.rb' - 'spec/features/admin/order_cycles_spec.rb' @@ -1995,6 +2033,8 @@ Style/HashSyntax: - 'spec/features/admin/subscriptions_spec.rb' - 'spec/features/admin/variant_overrides_spec.rb' - 'spec/features/consumer/account/cards_spec.rb' + - 'spec/features/consumer/cookies_spec.rb' + - 'spec/features/consumer/footer_links_spec.rb' - 'spec/features/consumer/shopping/products_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' - 'spec/jobs/subscription_placement_job_spec.rb' @@ -2005,7 +2045,6 @@ Style/HashSyntax: - 'spec/lib/open_food_network/tag_rule_applicator_spec.rb' - 'spec/mailers/order_mailer_spec.rb' - 'spec/models/calculator/weight_spec.rb' - - 'spec/models/cart_spec.rb' - 'spec/models/enterprise_fee_spec.rb' - 'spec/models/enterprise_spec.rb' - 'spec/models/exchange_spec.rb' @@ -2060,20 +2099,18 @@ Style/MethodCallWithoutArgsParentheses: Exclude: - 'app/controllers/spree/admin/payment_methods_controller_decorator.rb' - 'app/views/json/_groups.rabl' - - 'spec/controllers/spree/orders_controller_spec.rb' + - 'spec/controllers/cart_controller_spec.rb' - 'spec/features/consumer/registration_spec.rb' - 'spec/models/spree/payment_method_spec.rb' - 'spec/support/request/ui_component_helper.rb' -# Offense count: 13 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: Exclude: - - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/helpers/enterprises_helper.rb' - - 'app/models/cart.rb' - 'app/models/spree/product_decorator.rb' - 'lib/open_food_network/distribution_change_validator.rb' - 'lib/open_food_network/feature_toggle.rb' @@ -2083,7 +2120,7 @@ Style/MethodDefParentheses: - 'spec/support/request/web_helper.rb' # Offense count: 1 -Style/MethodMissing: +Style/MissingRespondToMissing: Exclude: - 'app/helpers/application_helper.rb' @@ -2139,13 +2176,12 @@ Style/Next: Exclude: - 'lib/tasks/data.rake' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. Style/NilComparison: Exclude: - 'lib/discourse/single_sign_on.rb' - 'lib/open_food_network/order_grouper.rb' - - 'spec/features/admin/enterprise_fees_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/spree/order_spec.rb' @@ -2196,7 +2232,7 @@ Style/OneLineConditional: # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: AllowSafeAssignment. +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: Exclude: - 'app/controllers/checkout_controller.rb' @@ -2253,7 +2289,7 @@ Style/RedundantParentheses: - 'spec/controllers/admin/enterprises_controller_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' -# Offense count: 10 +# Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -2264,7 +2300,6 @@ Style/RedundantReturn: - 'app/models/enterprise_fee.rb' - 'app/models/spree/adjustment_decorator.rb' - 'app/models/spree/classification_decorator.rb' - - 'app/models/spree/order_populator_decorator.rb' - 'app/serializers/api/admin/enterprise_serializer.rb' # Offense count: 98 @@ -2300,7 +2335,7 @@ Style/RedundantSelf: - 'lib/open_food_network/reports/report.rb' - 'lib/open_food_network/variant_and_line_item_naming.rb' -# Offense count: 12 +# Offense count: 16 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed @@ -2313,6 +2348,7 @@ Style/RegexpLiteral: - 'app/models/enterprise_group.rb' - 'app/models/spree/preference_decorator.rb' - 'lib/discourse/single_sign_on.rb' + - 'spec/mailers/subscription_mailer_spec.rb' - 'spec/models/content_configuration_spec.rb' # Offense count: 4 @@ -2406,6 +2442,14 @@ Style/UnlessElse: - 'app/models/enterprise.rb' - 'lib/open_food_network/order_grouper.rb' +# Offense count: 5 +# Cop supports --auto-correct. +Style/UnneededCondition: + Exclude: + - 'app/controllers/admin/resource_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/serializers/api/order_serializer.rb' + # Offense count: 33 # Cop supports --auto-correct. Style/UnneededInterpolation: @@ -2452,7 +2496,7 @@ Style/UnneededPercentQ: - 'spec/features/consumer/producers_spec.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 6607 +# Offense count: 6683 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/Gemfile.lock b/Gemfile.lock index 6f2939c41d6..a63804e6bf2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -484,6 +484,7 @@ GEM immigrant (0.3.6) activerecord (>= 3.0) ipaddress (0.8.3) + jaro_winkler (1.5.1) journey (1.0.4) jquery-migrate-rails (1.2.1) jquery-rails (2.2.2) @@ -665,7 +666,8 @@ GEM rspec-retry (0.5.6) rspec-core (> 3.3, < 3.8) rspec-support (3.7.1) - rubocop (0.55.0) + rubocop (0.57.2) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5) powerpack (~> 0.1)