mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Safely autocorrect Rails/StripHeredoc
Inspecting 1484 files
........................................................................................................................................................................................................................................................C.........................................................................................................................................CC...........................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................C....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Offenses:
app/models/content_configuration.rb:74:48: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
preference :footer_links_md, :text, default: <<-EOS.strip_heredoc
^^^^^^^^^^^^^^^^^^^^
app/queries/customers_with_balance.rb:23:5: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-SQL.strip_heredoc
^^^^^^^^^^^^^^^^^^^^
app/queries/outstanding_balance.rb:32:5: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-SQL.strip_heredoc
^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:71:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:84:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:96:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:109:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:119:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:135:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:151:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:161:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:168:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:182:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:192:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:208:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:218:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:228:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:235:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:253:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:274:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:289:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:310:13: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/reporting/reports/enterprise_fee_summary/scope.rb:369:15: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
<<-JOIN_STRING.strip_heredoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/data/truncate_data.rake:35:17: C: [Corrected] Rails/StripHeredoc: Use squiggly heredoc (<<~) instead of strip_heredoc.
message = <<-MSG.strip_heredoc
^^^^^^^^^^^^^^^^^^^^
lib/tasks/data/truncate_data.rake:36:1: C: [Corrected] Layout/HeredocIndentation: Use 2 spaces for indentation in a heredoc.
\n ...
^^^^^^^^
1484 files inspected, 25 offenses detected, 25 offenses corrected
This commit is contained in:
@@ -700,16 +700,6 @@ Rails/SquishedSQLHeredocs:
|
||||
- 'app/queries/outstanding_balance.rb'
|
||||
- 'spec/queries/outstanding_balance_spec.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/StripHeredoc:
|
||||
Exclude:
|
||||
- 'app/models/content_configuration.rb'
|
||||
- 'app/queries/customers_with_balance.rb'
|
||||
- 'app/queries/outstanding_balance.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/tasks/data/truncate_data.rake'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
|
||||
@@ -71,7 +71,7 @@ class ContentConfiguration < Spree::Preferences::Configuration
|
||||
preference :footer_pinterest_url, :string, default: ""
|
||||
preference :footer_email, :string, default: "hello@openfoodnetwork.org"
|
||||
preference :community_forum_url, :string, default: "http://community.openfoodnetwork.org"
|
||||
preference :footer_links_md, :text, default: <<-EOS.strip_heredoc
|
||||
preference :footer_links_md, :text, default: <<~EOS
|
||||
[Newsletter sign-up](/)
|
||||
|
||||
[News](/)
|
||||
|
||||
@@ -20,7 +20,7 @@ class CustomersWithBalance
|
||||
# The resulting orders are in states that belong after the checkout. Only these can be considered
|
||||
# for a customer's balance.
|
||||
def left_join_complete_orders
|
||||
<<-SQL.strip_heredoc
|
||||
<<~SQL
|
||||
LEFT JOIN spree_orders ON spree_orders.customer_id = customers.id
|
||||
AND #{finalized_states.to_sql}
|
||||
SQL
|
||||
|
||||
@@ -29,7 +29,7 @@ class OutstandingBalance
|
||||
# Arel doesn't support CASE statements until v7.1.0 so we'll have to wait with SQL literals
|
||||
# a little longer. See https://github.com/rails/arel/pull/400 for details.
|
||||
def statement
|
||||
<<-SQL.strip_heredoc
|
||||
<<~SQL
|
||||
CASE WHEN "spree_orders"."state" IN #{non_fulfilled_states_group.to_sql} THEN "spree_orders"."payment_total"
|
||||
WHEN "spree_orders"."state" IS NOT NULL THEN "spree_orders"."payment_total" - "spree_orders"."total"
|
||||
ELSE 0 END
|
||||
|
||||
@@ -68,7 +68,7 @@ module Reporting
|
||||
|
||||
def include_adjustment_metadata
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN adjustment_metadata
|
||||
ON (adjustment_metadata.adjustment_id = spree_adjustments.id)
|
||||
JOIN_STRING
|
||||
@@ -81,7 +81,7 @@ module Reporting
|
||||
# * Hub
|
||||
def include_order_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_orders
|
||||
ON (
|
||||
spree_orders.id = spree_adjustments.order_id
|
||||
@@ -93,7 +93,7 @@ module Reporting
|
||||
join_scope("LEFT OUTER JOIN customers ON (customers.id = spree_orders.customer_id)")
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises AS hubs
|
||||
ON (hubs.id = spree_orders.distributor_id)
|
||||
JOIN_STRING
|
||||
@@ -106,7 +106,7 @@ module Reporting
|
||||
# * Payment method
|
||||
def include_payment_fee_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_payment_methods
|
||||
ON (
|
||||
spree_adjustments.originator_type = 'Spree::PaymentMethod'
|
||||
@@ -116,7 +116,7 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises AS payment_hubs
|
||||
ON (
|
||||
spree_payment_methods.id IS NOT NULL
|
||||
@@ -132,7 +132,7 @@ module Reporting
|
||||
# * Shipping method
|
||||
def include_shipping_fee_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_shipping_methods
|
||||
ON (
|
||||
spree_adjustments.originator_type = 'Spree::ShippingMethod'
|
||||
@@ -148,7 +148,7 @@ module Reporting
|
||||
# * Enterprise fee tax category
|
||||
def include_enterprise_fee_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprise_fees
|
||||
ON (
|
||||
spree_adjustments.originator_type = 'EnterpriseFee'
|
||||
@@ -158,14 +158,14 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises
|
||||
ON (enterprises.id = enterprise_fees.enterprise_id)
|
||||
JOIN_STRING
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_tax_categories
|
||||
ON (spree_tax_categories.id = enterprise_fees.tax_category_id)
|
||||
JOIN_STRING
|
||||
@@ -179,7 +179,7 @@ module Reporting
|
||||
# * Distributor
|
||||
def include_order_source_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_orders AS adjustment_source_orders
|
||||
ON (
|
||||
spree_adjustments.adjustable_type = 'Spree::Order'
|
||||
@@ -189,7 +189,7 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises AS adjustment_source_distributors
|
||||
ON (adjustment_source_distributors.id = adjustment_source_orders.distributor_id)
|
||||
JOIN_STRING
|
||||
@@ -205,7 +205,7 @@ module Reporting
|
||||
# * Tax category of product, if enterprise fee tells to inherit
|
||||
def include_line_item_source_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_line_items
|
||||
ON (
|
||||
spree_adjustments.adjustable_type = 'Spree::LineItem'
|
||||
@@ -215,7 +215,7 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_variants
|
||||
ON (
|
||||
spree_adjustments.adjustable_type = 'Spree::LineItem'
|
||||
@@ -225,14 +225,14 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_products
|
||||
ON (spree_products.id = spree_variants.product_id)
|
||||
JOIN_STRING
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN spree_tax_categories AS product_tax_categories
|
||||
ON (
|
||||
enterprise_fees.inherits_tax_category IS TRUE
|
||||
@@ -250,7 +250,7 @@ module Reporting
|
||||
# * Incoming exchange variant
|
||||
def include_incoming_exchange_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN
|
||||
(
|
||||
exchange_variants AS incoming_exchange_variants
|
||||
@@ -271,7 +271,7 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises AS incoming_exchange_enterprises
|
||||
ON (incoming_exchange_enterprises.id = incoming_exchanges.sender_id)
|
||||
JOIN_STRING
|
||||
@@ -286,7 +286,7 @@ module Reporting
|
||||
# * Outgoing exchange variant
|
||||
def include_outgoing_exchange_details
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN
|
||||
(
|
||||
exchange_variants AS outgoing_exchange_variants
|
||||
@@ -307,7 +307,7 @@ module Reporting
|
||||
)
|
||||
|
||||
join_scope(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
LEFT OUTER JOIN enterprises AS outgoing_exchange_enterprises
|
||||
ON (outgoing_exchange_enterprises.id = outgoing_exchanges.receiver_id)
|
||||
JOIN_STRING
|
||||
@@ -366,7 +366,7 @@ module Reporting
|
||||
def select_attributes
|
||||
chain_to_scope do
|
||||
select(
|
||||
<<-JOIN_STRING.strip_heredoc
|
||||
<<~JOIN_STRING
|
||||
SUM(spree_adjustments.amount) AS total_amount,
|
||||
spree_payment_methods.name AS payment_method_name,
|
||||
spree_shipping_methods.name AS shipping_method_name,
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace :ofn do
|
||||
end
|
||||
|
||||
def warn_with_confirmation
|
||||
message = <<-MSG.strip_heredoc
|
||||
\n
|
||||
<% highlighted_message = "This will permanently change DB contents. This is not meant to be run in production as it needs more thorough testing." %>
|
||||
<%= color(highlighted_message, :blink, :on_red) %>
|
||||
Are you sure you want to proceed? (y/N)
|
||||
message = <<~MSG
|
||||
\n
|
||||
<% highlighted_message = "This will permanently change DB contents. This is not meant to be run in production as it needs more thorough testing." %>
|
||||
<%= color(highlighted_message, :blink, :on_red) %>
|
||||
Are you sure you want to proceed? (y/N)
|
||||
MSG
|
||||
|
||||
exit unless HighLine.new.agree(message) { |question| question.default = "N" }
|
||||
|
||||
Reference in New Issue
Block a user