spree-contrib/spree_drop_ship

View on GitHub

Showing 3 of 7 total issues

Method finalize! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def finalize!
        super

        shipments.each do |shipment|
          next unless ::SpreeDropShip::Config[:send_supplier_email] && shipment.supplier.present?
Severity: Minor
Found in app/models/spree/order_decorator.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def index
        params[:q] ||= {}
        # params[:q][:completed_at_null] ||= '1'
        # @show_only_incomplete = params[:q][:completed_at_null].present?
        # params[:q][:s] ||= @show_only_incomplete ? 'created_at desc' : 'completed_at desc'
Severity: Minor
Found in app/controllers/spree/admin/shipments_controller.rb - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method create_stock_items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def create_stock_items
        ::Spree::StockLocation.all.find_each do |stock_location|
          if stock_location.supplier_id.blank? || suppliers.pluck(:id).include?(stock_location.supplier_id)
            stock_location.propagate_variant(self) if stock_location.propagate_all_variants?
          end
Severity: Minor
Found in app/models/spree/variant_decorator.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language