Rubocop: Correct Lint/UselessAssignment offences, disable for /spec in main config

This commit is contained in:
Rob Harrington
2017-06-23 16:37:02 +10:00
parent 7079952f6b
commit e5340cb53a
14 changed files with 19 additions and 23 deletions

View File

@@ -34,6 +34,14 @@ Style/StringLiterals:
Lint/AmbiguousBlockAssociation:
Enabled: false
# Heaps of offences (> 100) in specs, mostly in situations where two or more
# instances of a model are required, but only one is referenced. Difficult to
# fix without making the spec look messy or rewriting it.
# Should definitely fix at some point.
Lint/UselessAssignment:
Exclude:
- spec/**/*
# No alternative to this one until we upgrade to Rails 4 and can use #find_by
Rails/DynamicFindBy:
Enabled: false

View File

@@ -154,10 +154,6 @@ Lint/UselessAccessModifier:
- 'lib/open_food_network/reports/bulk_coop_report.rb'
- 'spec/lib/open_food_network/reports/report_spec.rb'
# Offense count: 143
Lint/UselessAssignment:
Enabled: false
# Offense count: 340
Lint/Void:
Exclude:

View File

@@ -167,8 +167,8 @@ class CheckoutController < Spree::CheckoutController
customer_preferred_bill_address, customer_preferred_ship_address = @order.customer.bill_address, @order.customer.ship_address if @order.customer
@order.bill_address ||= customer_preferred_bill_address ||= preferred_bill_address || last_used_bill_address || Spree::Address.default
@order.ship_address ||= customer_preferred_ship_address ||= preferred_ship_address || last_used_ship_address || Spree::Address.default
@order.bill_address ||= customer_preferred_bill_address || preferred_bill_address || last_used_bill_address || Spree::Address.default
@order.ship_address ||= customer_preferred_ship_address || preferred_ship_address || last_used_ship_address || Spree::Address.default
end
def after_payment

View File

@@ -30,7 +30,6 @@ class DiscourseSsoController < ApplicationController
def sso_url
secret = discourse_sso_secret!
discourse_url = discourse_url!
sso = Discourse::SingleSignOn.parse(request.query_string, secret)
sso.email = spree_current_user.email
sso.username = spree_current_user.login

View File

@@ -101,7 +101,6 @@ Spree::Admin::ReportsController.class_eval do
# -- Build Report with Order Grouper
@report = OpenFoodNetwork::OrderCycleManagementReport.new spree_current_user, params
@table = @report.table_items
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], "order_cycle_management_#{timestamp}.csv")
end
@@ -126,7 +125,6 @@ Spree::Admin::ReportsController.class_eval do
@report = OpenFoodNetwork::PackingReport.new spree_current_user, params
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns
@table = order_grouper.table(@report.table_items)
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
render_report(@report.header, @table, params[:csv], "packing_#{timestamp}.csv")
end

View File

@@ -5,12 +5,12 @@ module Admin
end
def admin_image_settings_geometry_from_style(style)
geometry, format = admin_image_settings_split_style style
geometry, _format = admin_image_settings_split_style style
geometry
end
def admin_image_settings_format_from_style(style)
geometry, format = admin_image_settings_split_style style
_geometry, format = admin_image_settings_split_style style
format
end

View File

@@ -37,7 +37,7 @@ class UpdateAccountInvoices
if billable_periods.any?
oldest_enterprise = billable_periods.first.enterprise
address = oldest_enterprise.address.dup
first, space, last = (oldest_enterprise.contact || "").partition(' ')
first, _space, last = (oldest_enterprise.contact || "").partition(' ')
address.update_attributes(phone: oldest_enterprise.phone) if oldest_enterprise.phone.present?
address.update_attributes(firstname: first, lastname: last) if first.present? && last.present?
account_invoice.order.update_attributes(bill_address: address, ship_address: address)

View File

@@ -3,8 +3,6 @@ class Cart < ActiveRecord::Base
belongs_to :user, :class_name => Spree.user_class
def add_variant variant_id, quantity, distributor, order_cycle, currency
variant = Spree::Variant.find(variant_id)
order = create_or_find_order_for_distributor distributor, order_cycle, currency
@populator = Spree::OrderPopulator.new(order, currency)

View File

@@ -21,7 +21,7 @@ module Spree
def enterprise
enterprise_id = key.match(product_selection_from_inventory_only_regex)[1]
enterprise = Enterprise.find enterprise_id
Enterprise.find(enterprise_id)
end
def product_selection_from_inventory_only_regex

View File

@@ -56,7 +56,7 @@ class Api::CachedProductSerializer < ActiveModel::Serializer
#return a sanitized html description
def description_html
d = sanitize(object.description, options = {tags: "p, b, strong, em, i"})
d = sanitize(object.description, tags: "p, b, strong, em, i")
d.to_s.html_safe
end

View File

@@ -42,15 +42,14 @@ module OpenFoodNetwork
tax_category = variant.product.tax_category
if tax_category && tax_category.tax_rates.present?
tax_rate = tax_category.tax_rates.first
line_item = mock_line_item(variant, tax_category)
line_item = mock_line_item(variant)
tax_rate.calculator.compute line_item
else
0
end
end
def mock_line_item(variant, tax_category)
product = OpenStruct.new tax_category: tax_category
def mock_line_item(variant)
line_item = Spree::LineItem.new quantity: 1
line_item.define_singleton_method(:product) { variant.product }
line_item.define_singleton_method(:price) { variant.price }

View File

@@ -40,7 +40,6 @@ module OpenFoodNetwork
def payment_method_row(order)
ba = order.billing_address
da = order.distributor.andand.address
[ba.firstname,
ba.lastname,
order.distributor.andand.name,
@@ -56,7 +55,6 @@ module OpenFoodNetwork
def delivery_row(order)
sa = order.shipping_address
da = order.distributor.andand.address
[sa.firstname,
sa.lastname,
order.distributor.andand.name,

View File

@@ -93,7 +93,7 @@ module OpenFoodNetwork
def shipping_cost_for(order)
shipping_cost = order.adjustments.find_by_label("Shipping").andand.amount
shipping_cost = shipping_cost.nil? ? 0.0 : shipping_cost
shipping_cost.nil? ? 0.0 : shipping_cost
end
def tax_included_in(line_item)

View File

@@ -29,7 +29,7 @@ namespace :karma do
def application_spec_files
sprockets = Rails.application.assets
sprockets.append_path Rails.root.join("spec/javascripts")
files = Rails.application.assets.find_asset("application_spec.js").to_a.map {|e| e.pathname.to_s }
Rails.application.assets.find_asset("application_spec.js").to_a.map {|e| e.pathname.to_s }
end
def unit_js(files)