drhenner/ror_ecommerce

View on GitHub

Showing 203 of 346 total issues

Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    all_selected = true
    if params[:shipping_category].present?
      params[:shipping_category].each_pair do |category_id, rate_id|#[rate]
        if rate_id.present?
Severity: Minor
Found in app/controllers/admin/shopping/checkout/shipping_methods_controller.rb - About 45 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 sanitize_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitize_data
    self.email      = self.email.strip.downcase         unless email.blank?
    self.first_name = self.first_name.strip.capitalize  unless first_name.nil?
    self.last_name  = self.last_name.strip.capitalize   unless last_name.nil?

Severity: Minor
Found in app/models/user.rb - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    all_selected = true
    redirect_to(shopping_orders_url) and return unless params[:shipping_category].present?
    params[:shipping_category].each_pair do |category_id, rate_id|#[rate]
      if rate_id.present?
Severity: Minor
Found in app/controllers/shopping/shipping_methods_controller.rb - About 45 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

Consider simplifying this complex logical expression.
Open

        if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
          dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
          result = xhr.responseText

          try {
Severity: Major
Found in app/assets/javascripts/zepto.js - About 40 mins to fix

    Function remove has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
    Severity: Minor
    Found in app/assets/javascripts/jquery/jquery-migrate-1.1.1.js - About 35 mins to fix

      Function anim has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        function anim(el, speed, opacity, scale, callback) {
      Severity: Minor
      Found in app/assets/javascripts/zepto.js - About 35 mins to fix

        Function add has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        jQuery.event.add = function( elem, types, handler, data, selector ){
        Severity: Minor
        Found in app/assets/javascripts/jquery/jquery-migrate-1.1.1.js - About 35 mins to fix

          Function jq_param_sub has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            function jq_param_sub( is_fragment, get_func, url, params, merge_mode ) {
          Severity: Minor
          Found in app/assets/javascripts/jqwizard/bbq.js - About 35 mins to fix

            Function _w has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                var _w = function(f, a1, a2, a3, a4)
            Severity: Minor
            Found in app/assets/javascripts/jquery.datePicker-2.1.2.js - About 35 mins to fix

              Function remove has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                function remove(element, events, fn, selector, capture){
              Severity: Minor
              Found in app/assets/javascripts/zepto.js - About 35 mins to fix

                Method add_cart_items has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def add_cart_items(items, qty, customer, cart_item_type_id, variant_id)
                Severity: Minor
                Found in app/models/cart.rb - About 35 mins to fix

                  Method new_transaction_ledgers has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def new_transaction_ledgers( transactor, credit_transaction_account_id, debit_transaction_account_id, amount, at)
                  Severity: Minor
                  Found in app/models/transaction.rb - About 35 mins to fix

                    Method add_variant has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def add_variant(variant_id, customer, qty = 1, cart_item_type_id = ItemType::SHOPPING_CART_ID, admin_purchase = false)
                    Severity: Minor
                    Found in app/models/cart.rb - About 35 mins to fix

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

                        def session_cart!
                          if cookies[:cart_id]
                            @session_cart = Cart.includes(:shopping_cart_items).find_by_id(cookies[:cart_id])
                            unless @session_cart
                              @session_cart = Cart.create(:user_id => current_user_id)
                      Severity: Minor
                      Found in app/controllers/application_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 items_to_add_or_destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def items_to_add_or_destroy(items_in_cart, order)
                          #destroy_any_order_item_that_was_removed_from_cart
                          destroy_order_items_not_in_cart!(items_in_cart, order)
                         # order.order_items.delete_all #destroy(order_item.id)
                          items = order.order_items.inject({}) {|h, item| h[item.variant_id].nil? ? h[item.variant_id] = [item.id]  : h[item.variant_id] << item.id; h}
                      Severity: Minor
                      Found in app/models/cart.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 charge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def charge( amount, profile_key, options ={})
                              options[:order_id] ||= unique_order_number
                              if GATEWAY.respond_to?(:purchase)
                                process( 'charge', amount ) do |gw|
                                  gw.purchase( amount, profile_key, options )
                      Severity: Minor
                      Found in app/models/payment.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 remove_items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def remove_items(variant, final_quantity)
                      
                          current_qty = 0
                          items_to_remove = []
                          self.order_items.each_with_index do |order_item, i|
                      Severity: Minor
                      Found in app/models/order.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

                      Avoid too many return statements within this function.
                      Open

                                    return false;
                      Severity: Major
                      Found in app/assets/javascripts/markitup/jquery.markitup.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return $(this.scope).width() < settings.small_breakpoint;
                        Severity: Major
                        Found in app/assets/javascripts/foundation/foundation.section.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                        return false;
                          Severity: Major
                          Found in app/assets/javascripts/markitup/jquery.markitup.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language