From ce965250b5f94319e13e5e3743c4c44de5ec4aa9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Thu, 15 Mar 2018 18:22:06 -0700 Subject: [PATCH] Fix yard warnings and errors This fixes all YARD warnings and errors in core (mostly due to slightly wrong syntax). It doesn't touch carton_mailer.rb, which has 3 warnings, but I intend to address them in a separate PR. --- core/app/models/spree/distributed_amounts_handler.rb | 2 +- core/app/models/spree/inventory_unit.rb | 3 ++- core/app/models/spree/order.rb | 2 +- core/app/models/spree/order_contents.rb | 6 +++--- core/app/models/spree/product.rb | 2 +- .../promotion/rules/first_repeat_purchase_since.rb | 1 - core/app/models/spree/promotion/rules/nth_order.rb | 1 - core/app/models/spree/tax_calculator/shipping_rate.rb | 5 +++-- core/app/models/spree/variant.rb | 4 +--- core/app/models/spree/wallet.rb | 2 +- core/lib/spree/app_configuration.rb | 10 +++++----- core/lib/spree/core/role_configuration.rb | 2 +- core/lib/spree/core/search/variant.rb | 2 +- 13 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core/app/models/spree/distributed_amounts_handler.rb b/core/app/models/spree/distributed_amounts_handler.rb index 36e276bbf9f..a51ea086177 100644 --- a/core/app/models/spree/distributed_amounts_handler.rb +++ b/core/app/models/spree/distributed_amounts_handler.rb @@ -9,7 +9,7 @@ def initialize(line_items, total_amount) @total_amount = total_amount end - # @param [LineItem] one of the line_items distributed over + # @param line_item [LineItem] one of the line_items distributed over # @return [BigDecimal] the weighted adjustment for this line_item def amount(line_item) distributed_amounts[line_item.id].to_d diff --git a/core/app/models/spree/inventory_unit.rb b/core/app/models/spree/inventory_unit.rb index 0269797eb79..45a9bc05aab 100644 --- a/core/app/models/spree/inventory_unit.rb +++ b/core/app/models/spree/inventory_unit.rb @@ -47,10 +47,11 @@ def order=(_) .backordered.order(Spree::Order.arel_table[:completed_at].asc) end + # @method backordered_for_stock_item(stock_item) # @param stock_item [Spree::StockItem] the stock item of the desired # inventory units # @return [ActiveRecord::Relation] backordered - # inventory units for the given stock item + # inventory units for the given stock item scope :backordered_for_stock_item, ->(stock_item) do backordered_per_variant(stock_item) .where(spree_shipments: { stock_location_id: stock_item.stock_location_id }) diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 378898851d3..2c910eb7cf7 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -359,7 +359,7 @@ def find_line_item_by_variant(variant, options = {}) # "Are these line items equal" decision. # # When adding to cart, an extension would send something like: - # params[:product_customizations]={...} + # params[:product_customizations]=... # # and would provide: # diff --git a/core/app/models/spree/order_contents.rb b/core/app/models/spree/order_contents.rb index b15f54adfdb..87f7cd1f6e8 100644 --- a/core/app/models/spree/order_contents.rb +++ b/core/app/models/spree/order_contents.rb @@ -11,10 +11,10 @@ def initialize(order) # Add a line items to the order if there is inventory to do so # and populate Promotions # - # @params [Spree::Variant] :variant The variant the line_item should + # @param [Spree::Variant] variant The variant the line_item should # be associated with - # @params [Integer] :quantity The line_item quantity - # @param [Hash] :options Options for the adding proccess + # @param [Integer] quantity The line_item quantity + # @param [Hash] options Options for the adding proccess # Valid options: # shipment: [Spree::Shipment] LineItem target shipment # diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index e2d21442532..5062b897b5e 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -302,7 +302,7 @@ def display_image # Finds the variant property rule that matches the provided option value ids. # - # @param [Array] list of option value ids + # @param option_value_ids [Array] list of option value ids # @return [Spree::VariantPropertyRule] the matching variant property rule def find_variant_property_rule(option_value_ids) variant_property_rules.find do |rule| diff --git a/core/app/models/spree/promotion/rules/first_repeat_purchase_since.rb b/core/app/models/spree/promotion/rules/first_repeat_purchase_since.rb index deb8abcaca1..ccd47ef7380 100644 --- a/core/app/models/spree/promotion/rules/first_repeat_purchase_since.rb +++ b/core/app/models/spree/promotion/rules/first_repeat_purchase_since.rb @@ -16,7 +16,6 @@ def applicable?(promotable) # # This is eligible if the user's most recently completed order is more than the preferred days ago # @param order [Spree::Order] - # @option options def eligible?(order, _options = {}) return false unless order.user diff --git a/core/app/models/spree/promotion/rules/nth_order.rb b/core/app/models/spree/promotion/rules/nth_order.rb index 24838bf42c7..d5f0b337a85 100644 --- a/core/app/models/spree/promotion/rules/nth_order.rb +++ b/core/app/models/spree/promotion/rules/nth_order.rb @@ -18,7 +18,6 @@ def applicable?(promotable) # # Use the first order rule if you want a promotion to be applied to the first order for a user. # @param order [Spree::Order] - # @option options def eligible?(order, _options = {}) return false unless order.user diff --git a/core/app/models/spree/tax_calculator/shipping_rate.rb b/core/app/models/spree/tax_calculator/shipping_rate.rb index 5e812439a04..3ec7bf036e5 100644 --- a/core/app/models/spree/tax_calculator/shipping_rate.rb +++ b/core/app/models/spree/tax_calculator/shipping_rate.rb @@ -20,8 +20,7 @@ class ShippingRate # Create a new tax calculator. # - # @param [Spree::ShippingRate] shipping_rate the shipping rate to - # calculate taxes on + # @param [Spree::Order] order the order to calculate taxes on # @return [Spree::TaxCalculator::ShippingRate] def initialize(order) if order.is_a?(::Spree::ShippingRate) @@ -37,6 +36,8 @@ def initialize(order) # Calculate taxes for a shipping rate. # + # @param [Spree::ShippingRate] shipping_rate the shipping rate to + # calculate taxes on # @return [Array] the calculated taxes for the # shipping rate def calculate(shipping_rate) diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rb index db4060b6e08..dd94f1e5c4c 100644 --- a/core/app/models/spree/variant.rb +++ b/core/app/models/spree/variant.rb @@ -94,7 +94,7 @@ class Variant < Spree::Base # a parameter, the scope is limited to variants that are in stock in the # provided stock locations. # - # If you want to also include backorderable variants see {[suppliable}} + # If you want to also include backorderable variants see {Spree::Variant.suppliable} # # @param stock_locations [Array] the stock locations to check # @return [ActiveRecord::Relation] @@ -282,8 +282,6 @@ def price_selector # Chooses an appropriate price for the given pricing options # # @see Spree::Variant::PriceSelector#price_for - # @param [Spree::Config.pricing_options_class] An instance of pricing options - # @return [Spree::Money] The chosen price as a Money object delegate :price_for, to: :price_selector # Returns the difference in price from the master variant diff --git a/core/app/models/spree/wallet.rb b/core/app/models/spree/wallet.rb index cc7e8ab4b1e..4f588edaaa8 100644 --- a/core/app/models/spree/wallet.rb +++ b/core/app/models/spree/wallet.rb @@ -55,7 +55,7 @@ def default_wallet_payment_source end # Change the default WalletPaymentSource for this wallet. - # @param source [WalletPaymentSource] The payment source to set as the default. + # @param wallet_payment_source [WalletPaymentSource] The payment source to set as the default. # It must be in the wallet already. Pass nil to clear the default. # @return [void] def default_wallet_payment_source=(wallet_payment_source) diff --git a/core/lib/spree/app_configuration.rb b/core/lib/spree/app_configuration.rb index 53be7e82322..2a877feed54 100644 --- a/core/lib/spree/app_configuration.rb +++ b/core/lib/spree/app_configuration.rb @@ -104,7 +104,7 @@ class AppConfiguration < Preferences::Configuration preference :inventory_cache_threshold, :integer # @!attribute [rw] checkout_zone - # @return [String] Name of a {Zone}, which limits available countries to those included in that zone. (default: +nil+) + # @return [String] Name of a {Spree::Zone}, which limits available countries to those included in that zone. (default: +nil+) preference :checkout_zone, :string, default: nil # @!attribute [rw] company @@ -118,7 +118,7 @@ class AppConfiguration < Preferences::Configuration # @!attribute [rw] default_country_id # @deprecated Use the default country ISO preference instead - # @return [Integer,nil] id of {Country} to be selected by default in dropdowns (default: nil) + # @return [Integer,nil] id of {Spree::Country} to be selected by default in dropdowns (default: nil) preference :default_country_id, :integer # @!attribute [rw] default_country_iso @@ -159,7 +159,7 @@ class AppConfiguration < Preferences::Configuration preference :max_level_in_taxons_menu, :integer, default: 1 # @!attribute [rw] order_mutex_max_age - # @return [Integer] Max age of {OrderMutex} in seconds (default: 2 minutes) + # @return [Integer] Max age of {Spree::OrderMutex} in seconds (default: 2 minutes) preference :order_mutex_max_age, :integer, default: 120 # @!attribute [rw] orders_per_page @@ -244,7 +244,7 @@ class AppConfiguration < Preferences::Configuration # Store credits configurations # @!attribute [rw] credit_to_new_allocation - # @return [Boolean] Creates a new allocation anytime {StoreCredit#credit} is called + # @return [Boolean] Creates a new allocation anytime {Spree::StoreCredit#credit} is called preference :credit_to_new_allocation, :boolean, default: false # @!attribute [rw] automatic_default_address @@ -262,7 +262,7 @@ class AppConfiguration < Preferences::Configuration # Allows restricting what currencies will be available. # # @!attribute [r] available_currencies - # @returns [Array] An array of available currencies from Money::Currency.all + # @return [Array] An array of available currencies from Money::Currency.all attr_writer :available_currencies def available_currencies @available_currencies ||= ::Money::Currency.all diff --git a/core/lib/spree/core/role_configuration.rb b/core/lib/spree/core/role_configuration.rb index a383dd3c2b0..002bbd51fe0 100644 --- a/core/lib/spree/core/role_configuration.rb +++ b/core/lib/spree/core/role_configuration.rb @@ -38,7 +38,7 @@ def instance end # Yields the instance of the singleton, used for configuration - # @yield_param instance [Spree::RoleConfiguration] + # @yieldparam instance [Spree::RoleConfiguration] def configure Spree::Deprecation.warn "Spree::RoleConfiguration.configure is deprecated. Call Spree::Config.roles.assign_permissions instead" yield(Spree::Config.roles) diff --git a/core/lib/spree/core/search/variant.rb b/core/lib/spree/core/search/variant.rb index 8d75132f608..8d377fc68e1 100644 --- a/core/lib/spree/core/search/variant.rb +++ b/core/lib/spree/core/search/variant.rb @@ -49,7 +49,7 @@ def results # Subclasses may override this to allow conditional filtering, etc. # # @api public - # @param word [String] One of the search words provided by the user. + # @param _word [String] One of the search words provided by the user. # e.g. a SKU # @return [Array] the list of search terms to use for this word def search_terms(_word)