From 4acb3f196252cfb53ac1030b4192e57c3df4afa5 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 19 May 2017 17:57:12 +1000 Subject: [PATCH] Rubocop: Use Relaxed.Ruby.Style as starting point for settings Updated .rubocop_todo.yml --- .rubocop.yml | 149 ++++++++++++++++++++----- .rubocop_todo.yml | 277 +++++----------------------------------------- 2 files changed, 149 insertions(+), 277 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7f97c35806..6512b37549 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ -inherit_from: .rubocop_todo.yml +inherit_from: + - .rubocop_todo.yml AllCops: Include: @@ -10,33 +11,131 @@ AllCops: - 'script/**/*' - !ruby/regexp /old_and_unused\.rb$/ - -# Picks up '.should == x' RSpec syntax -# TODO: convert to '.to eq' syntax? -Lint/Void: - Exclude: - - 'spec/**/*' - -Metrics/BlockLength: - Max: 200 - -Metrics/LineLength: - Max: 120 - -Metrics/MethodLength: - Enabled: false - -Metrics/ClassLength: - Max: 500 - -Style/BracesAroundHashParameters: - Enabled: false +# OFN settings +# Cop settings that have been agreed upon by the OFN community Style/Documentation: Enabled: false -Style/EmptyLinesAroundClassBody: - Enabled: false - Style/StringLiterals: Enabled: false + +# Relaxed.Ruby.Style settings +# These styles are a starting point for the conversation around conventions +# They should be removed or moved above + tweaked as decisions are made +# NOTE: Cops which did not fail at the time of writing were removed + +Style/Alias: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylealias + +Style/BlockDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters + +Style/CommentAnnotation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylecommentannotation + +Style/DotPosition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledotposition + +Style/DoubleNegation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledoublenegation + +Style/FormatString: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleformatstring + +Style/IfUnlessModifier: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier + +Style/Lambda: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylelambda + +Style/MultilineBlockChain: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain + +Style/NegatedIf: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedif + +Style/NegatedWhile: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile + +Style/ParallelAssignment: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleparallelassignment + +Style/PercentLiteralDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters + +Style/Semicolon: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesemicolon + +Style/SingleLineMethods: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods + +Style/SpaceBeforeBlockBraces: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces + +Style/SpaceInsideParens: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens + +Style/TrailingCommaInArguments: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments + +Style/TrailingCommaInLiteral: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral + +Style/WordArray: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylewordarray + +Lint/AmbiguousRegexpLiteral: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral + +Lint/AssignmentInCondition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockNesting: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/LineLength: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8aa005479e..1102431ed5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-05-19 11:01:20 +1000 using RuboCop version 0.48.1. +# on 2017-05-20 10:48:13 +1000 using RuboCop version 0.48.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -22,28 +22,6 @@ Lint/AmbiguousBlockAssociation: Lint/AmbiguousOperator: Enabled: false -# Offense count: 2 -Lint/AmbiguousRegexpLiteral: - Exclude: - - 'app/models/column_preference.rb' - - 'spec/helpers/injection_helper_spec.rb' - -# Offense count: 13 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Exclude: - - 'app/controllers/admin/order_cycles_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/controllers/checkout_controller.rb' - - 'app/controllers/shop_controller.rb' - - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/helpers/spree/admin/navigation_helper_decorator.rb' - - 'app/jobs/finalize_account_invoices.rb' - - 'app/models/spree/line_item_decorator.rb' - - 'lib/spree/core/controller_helpers/order_decorator.rb' - - 'lib/spree/core/controller_helpers/respond_with_decorator.rb' - - 'spec/support/request/web_helper.rb' - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith. @@ -193,50 +171,17 @@ Lint/UselessAccessModifier: Lint/UselessAssignment: Enabled: false -# Offense count: 1 +# Offense count: 340 Lint/Void: Exclude: - - 'spec/**/*' - - 'app/serializers/api/enterprise_serializer.rb' + - app/serializers/api/enterprise_serializer.rb + - spec/**/* -# Offense count: 171 -Metrics/AbcSize: - Max: 285 - -# Offense count: 56 +# Offense count: 706 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: Max: 711 -# Offense count: 2 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 4 - -# Offense count: 34 -Metrics/CyclomaticComplexity: - Max: 23 - -# Offense count: 973 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 623 - -# Offense count: 24 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 633 - -# Offense count: 4 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - Max: 8 - -# Offense count: 25 -Metrics/PerceivedComplexity: - Max: 21 - # Offense count: 2 # Cop supports --auto-correct. Performance/CompareWithBlock: @@ -289,14 +234,6 @@ Style/AccessorMethodName: - 'app/models/spree/order_decorator.rb' - 'spec/support/request/shop_workflow.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: prefer_alias, prefer_alias_method -Style/Alias: - Exclude: - - 'app/models/spree/preferences/file_configuration.rb' - # Offense count: 77 # Cop supports --auto-correct. Style/AlignArray: @@ -357,16 +294,6 @@ Style/BarePercentLiterals: - 'spec/features/admin/variants_spec.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 89 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it -Style/BlockDelimiters: - Enabled: false - # Offense count: 41 # Cop supports --auto-correct. Style/BlockEndNewline: @@ -387,6 +314,13 @@ Style/BlockEndNewline: - 'spec/models/spree/variant_spec.rb' - 'spec/serializers/enterprise_serializer_spec.rb' +# Offense count: 209 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Enabled: false + # Offense count: 2 Style/CaseEquality: Exclude: @@ -437,23 +371,6 @@ Style/ColonMethodCall: - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'lib/discourse/single_sign_on.rb' -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: Keywords. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW -Style/CommentAnnotation: - Exclude: - - 'app/controllers/admin/enterprises_controller.rb' - - 'app/controllers/spree/admin/line_items_controller_decorator.rb' - - 'app/controllers/spree/admin/overview_controller_decorator.rb' - - 'app/controllers/spree/admin/reports_controller_decorator.rb' - - 'app/models/order_cycle.rb' - - 'lib/open_food_network/bulk_coop_report.rb' - - 'lib/open_food_network/orders_and_fulfillments_report.rb' - - 'lib/open_food_network/packing_report.rb' - - 'spec/models/cart_spec.rb' - - 'spec/models/product_distribution_spec.rb' - # Offense count: 8 # Cop supports --auto-correct. Style/CommentIndentation: @@ -461,36 +378,24 @@ Style/CommentIndentation: - 'Guardfile' - 'lib/open_food_network/packing_report.rb' -# Offense count: 8 +# Offense count: 13 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, 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/reports_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - 'app/helpers/injection_helper.rb' + - 'app/helpers/spree/admin/orders_helper_decorator.rb' - 'app/models/spree/calculator/flexi_rate_decorator.rb' - 'app/models/spree/calculator/per_item_decorator.rb' + - 'app/models/spree/payment_decorator.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' -# Offense count: 278 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Style/DotPosition: - Enabled: false - -# Offense count: 6 -Style/DoubleNegation: - Exclude: - - 'app/controllers/admin/order_cycles_controller.rb' - - 'app/controllers/api/enterprises_controller.rb' - - 'app/helpers/enterprises_helper.rb' - - 'app/models/product_importer.rb' - - 'spec/support/request/web_helper.rb' - # Offense count: 5 # Cop supports --auto-correct. Style/EachWithObject: @@ -520,7 +425,7 @@ Style/EmptyElse: - 'app/models/spreadsheet_entry.rb' - 'app/serializers/api/admin/basic_order_cycle_serializer.rb' -# Offense count: 287 +# Offense count: 222 # Cop supports --auto-correct. Style/EmptyLines: Enabled: false @@ -542,6 +447,13 @@ Style/EmptyLinesAroundAccessModifier: Style/EmptyLinesAroundBlockBody: Enabled: false +# Offense count: 27 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Style/EmptyLinesAroundClassBody: + Enabled: false + # Offense count: 7 # Cop supports --auto-correct. Style/EmptyLinesAroundExceptionHandlingKeywords: @@ -625,14 +537,6 @@ Style/FirstParameterIndentation: Exclude: - 'lib/open_food_network/permissions.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: format, sprintf, percent -Style/FormatString: - Exclude: - - 'app/helpers/order_cycles_helper.rb' - - 'lib/open_food_network/sales_tax_report.rb' - # Offense count: 87 # Configuration parameters: MinBodyLength. Style/GuardClause: @@ -654,19 +558,6 @@ Style/IfInsideElse: - 'app/controllers/spree/admin/overview_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/spree/admin/resource_controller_decorator.rb' - - 'app/controllers/spree/api/products_controller_decorator.rb' - - 'app/helpers/spree/admin/navigation_helper_decorator.rb' - - 'app/serializers/api/admin/for_order_cycle/enterprise_serializer.rb' - - 'lib/open_food_network/order_cycle_form_applicator.rb' - - 'spec/features/admin/orders_spec.rb' - # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. @@ -740,13 +631,6 @@ Style/InverseMethods: - 'app/controllers/admin/column_preferences_controller.rb' - 'spec/support/cancan_helper.rb' -# Offense count: 64 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Enabled: false - # Offense count: 80 # Cop supports --auto-correct. Style/LeadingCommentSpace: @@ -809,14 +693,6 @@ Style/MultilineArrayBraceLayout: - 'lib/open_food_network/xero_invoices_report.rb' - 'spec/archive/features/consumer/checkout_spec.rb' -# Offense count: 5 -Style/MultilineBlockChain: - Exclude: - - 'app/models/enterprise.rb' - - 'app/models/spree/calculator/default_tax_decorator.rb' - - 'lib/open_food_network/enterprise_fee_calculator.rb' - - 'lib/open_food_network/products_cache.rb' - # Offense count: 44 # Cop supports --auto-correct. Style/MultilineBlockLayout: @@ -877,24 +753,6 @@ Style/MutableConstant: - 'app/models/spree/payment_method_decorator.rb' - 'lib/discourse/single_sign_on.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: both, prefix, postfix -Style/NegatedIf: - Exclude: - - 'app/controllers/spree/admin/orders_controller_decorator.rb' - - 'app/models/spree/order_populator_decorator.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -Style/NegatedWhile: - Exclude: - - 'lib/tasks/data.rake' - - 'spec/controllers/line_items_controller_spec.rb' - - 'spec/controllers/spree/orders_controller_spec.rb' - - 'spec/factories.rb' - # Offense count: 8 # Cop supports --auto-correct. Style/NestedParenthesizedCalls: @@ -984,18 +842,6 @@ Style/OpMethod: Exclude: - 'app/models/exchange.rb' -# Offense count: 11 -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'app/controllers/checkout_controller.rb' - - 'app/controllers/spree/checkout_controller_decorator.rb' - - 'app/models/model_set.rb' - - 'spec/features/admin/enterprise_relationships_spec.rb' - - 'spec/features/admin/enterprise_roles_spec.rb' - - 'spec/models/enterprise_fee_spec.rb' - - 'spec/support/matchers/select2_matchers.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowSafeAssignment. @@ -1003,12 +849,6 @@ Style/ParenthesesAroundCondition: Exclude: - 'app/controllers/checkout_controller.rb' -# Offense count: 42 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - # Offense count: 25 # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. # NamePrefix: is_, has_, have_ @@ -1116,31 +956,6 @@ Style/RescueModifier: - 'app/controllers/spree/admin/reports_controller_decorator.rb' - 'lib/tasks/data.rake' -# Offense count: 28 -# Cop supports --auto-correct. -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Exclude: - - 'lib/tasks/karma.rake' - - 'spec/archive/features/consumer/checkout_spec.rb' - - 'spec/controllers/spree/admin/base_controller_spec.rb' - - 'spec/factories.rb' - - 'spec/features/admin/orders_spec.rb' - - 'spec/helpers/html_helper_spec.rb' - - 'spec/jobs/finalize_account_invoices_spec.rb' - - 'spec/lib/open_food_network/products_cache_spec.rb' - - 'spec/models/enterprise_relationship_spec.rb' - - 'spec/models/order_cycle_spec.rb' - - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/order_populator_spec.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: AllowIfMethodIsEmpty. -Style/SingleLineMethods: - Exclude: - - 'lib/open_food_network/paperclippable.rb' - # Offense count: 7 # Cop supports --auto-correct. Style/SpaceAfterColon: @@ -1176,13 +991,6 @@ Style/SpaceAroundEqualsInParameterDefault: Style/SpaceAroundOperators: Enabled: false -# Offense count: 188 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceBeforeBlockBraces: - Enabled: false - # Offense count: 6 # Cop supports --auto-correct. Style/SpaceBeforeComma: @@ -1238,11 +1046,6 @@ Style/SpaceInsideBrackets: Style/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 339 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Enabled: false - # Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -1314,29 +1117,6 @@ Style/TernaryParentheses: - 'app/controllers/spree/admin/payment_methods_controller_decorator.rb' - 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: - Exclude: - - 'lib/open_food_network/products_renderer.rb' - - 'spec/controllers/spree/admin/payment_methods_controller_spec.rb' - - 'spec/features/admin/tag_rules_spec.rb' - - 'spec/lib/open_food_network/tag_rule_applicator_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: - Exclude: - - 'app/serializers/api/enterprise_serializer.rb' - - 'lib/open_food_network/order_cycle_form_applicator.rb' - - 'lib/tasks/users.rake' - - 'spec/controllers/admin/order_cycles_controller_spec.rb' - - 'spec/models/column_preference_spec.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowNamedUnderscoreVariables. @@ -1404,10 +1184,3 @@ Style/VariableNumber: - 'spec/archive/features/consumer/checkout_spec.rb' - 'spec/lib/open_food_network/products_and_inventory_report_spec.rb' - 'spec/models/calculator/weight_spec.rb' - -# Offense count: 62 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, MinSize, WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - Enabled: false