diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index b6f0dd61e1..2cb5fb13d0 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -76,117 +76,6 @@ Lint/UselessAssignment: Exclude: - spec/**/* -## Relaxed.Ruby.Style SETTINGS -# -# These styles are a starting point for the conversation around conventions -# They should be removed or tweaked and moved above as decisions are made -# NOTE: Cops which did not fail at the time of writing were removed - -Layout/DotPosition: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styledotposition - -Layout/SpaceBeforeBlockBraces: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces - -Layout/SpaceInsideParens: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens - -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/DoubleNegation: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styledoublenegation - -Style/FormatString: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styleformatstring - -Style/HashEachMethods: - Enabled: false - -Style/HashTransformKeys: - Enabled: false - -Style/HashTransformValues: - Enabled: false - -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/TrailingCommaInArguments: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments - -Style/TrailingCommaInArrayLiteral: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral - -Style/TrailingCommaInHashLiteral: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral - -Style/WordArray: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#stylewordarray - -Style/SymbolArray: - Enabled: false - StyleGuide: https://rubocop.readthedocs.io/en/latest/cops_style/#stylesymbolarray - -Lint/AmbiguousRegexpLiteral: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral - -Lint/AssignmentInCondition: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition - Metrics/AbcSize: Enabled: true Max: 15 diff --git a/app/models/spree/gateway.rb b/app/models/spree/gateway.rb index b28350cf1b..b205cfae69 100644 --- a/app/models/spree/gateway.rb +++ b/app/models/spree/gateway.rb @@ -35,7 +35,7 @@ module Spree end def options - preferences.each_with_object({}){ |(key, value), memo| memo[key.to_sym] = value; } + preferences.transform_keys(&:to_sym) end def method_missing(method, *args) diff --git a/app/models/spree/preferences/preferable.rb b/app/models/spree/preferences/preferable.rb index e6f992beaa..2c0f61b2e2 100644 --- a/app/models/spree/preferences/preferable.rb +++ b/app/models/spree/preferences/preferable.rb @@ -93,7 +93,7 @@ module Spree end def clear_preferences - preferences.keys.each { |pref| preference_store.delete preference_cache_key(pref) } + preferences.each_key { |pref| preference_store.delete preference_cache_key(pref) } end private diff --git a/engines/order_management/app/services/order_management/subscriptions/summarizer.rb b/engines/order_management/app/services/order_management/subscriptions/summarizer.rb index 32c925fc03..377ff12eae 100644 --- a/engines/order_management/app/services/order_management/subscriptions/summarizer.rb +++ b/engines/order_management/app/services/order_management/subscriptions/summarizer.rb @@ -41,14 +41,14 @@ module OrderManagement # This uses `deliver_now` since it's called from inside a job def send_placement_summary_emails - @summaries.values.each do |summary| + @summaries.each_value do |summary| SubscriptionMailer.placement_summary_email(summary).deliver_now end end # This uses `deliver_now` since it's called from inside a job def send_confirmation_summary_emails - @summaries.values.each do |summary| + @summaries.each_value do |summary| SubscriptionMailer.confirmation_summary_email(summary).deliver_now end end diff --git a/lib/open_food_network/i18n_inflections.rb b/lib/open_food_network/i18n_inflections.rb index 5919da4000..e8bb21001e 100644 --- a/lib/open_food_network/i18n_inflections.rb +++ b/lib/open_food_network/i18n_inflections.rb @@ -55,7 +55,7 @@ module OpenFoodNetwork def build_i18n_key_lookup lookup = {} I18n.t("inflections")&.each do |key, translations| - translations.values.each do |translation| + translations.each_value do |translation| lookup[translation.downcase] = key end end diff --git a/lib/open_food_network/permissions.rb b/lib/open_food_network/permissions.rb index a3ddb7f36e..47620b4d14 100644 --- a/lib/open_food_network/permissions.rb +++ b/lib/open_food_network/permissions.rb @@ -43,13 +43,12 @@ module OpenFoodNetwork hubs = variant_override_hubs # Permissions granted by create_variant_overrides relationship from producer to hub - permissions = Hash[ - EnterpriseRelationship. - permitting(hubs.select("enterprises.id")). - with_permission(:create_variant_overrides). - group_by(&:child_id). - map { |child_id, ers| [child_id, ers.map(&:parent_id)] } - ] + permissions = + EnterpriseRelationship. + permitting(hubs.select("enterprises.id")). + with_permission(:create_variant_overrides). + group_by(&:child_id). + transform_values { |ers| ers.map(&:parent_id) } # Allow a producer hub to override it's own products without explicit permission hubs.is_primary_producer.each do |hub|