tryshoppe/core

View on GitHub

Showing 24 of 40 total issues

File chosen.jquery.js has 1042 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Chosen, a Select Box Enhancer for jQuery and Prototype
// by Patrick Filler for Harvest, http://getharvest.com
//
// Version 1.0.0
// Full source at https://github.com/harvesthq/chosen
Severity: Major
Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 2 days to fix

    Class OrderItem has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class OrderItem < ActiveRecord::Base
        self.table_name = 'shoppe_order_items'
    
        # The associated order
        #
    Severity: Minor
    Found in app/models/shoppe/order_item.rb - About 2 hrs to fix

      Method create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            Shoppe::Order.transaction do
              @order = Shoppe::Order.new(safe_params)
              @order.status = 'confirming'
      
      
      Severity: Minor
      Found in app/controllers/shoppe/orders_controller.rb - About 2 hrs 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

      Function register_observers has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Chosen.prototype.register_observers = function() {
            var _this = this;
      
            this.container.bind('mousedown.chosen', function(evt) {
              _this.container_mousedown(evt);
      Severity: Major
      Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 2 hrs to fix

        Function winnow_results has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            AbstractChosen.prototype.winnow_results = function() {
              var escapedSearchText, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
        
              this.no_results_clear();
              results = 0;
        Severity: Major
        Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 2 hrs to fix

          Method import has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.import(file)
                spreadsheet = open_spreadsheet(file)
                spreadsheet.default_sheet = spreadsheet.sheets.first
                header = spreadsheet.row(1)
                (2..spreadsheet.last_row).each do |i|
          Severity: Minor
          Found in app/models/shoppe/product.rb - About 2 hrs 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 nested_product_category_rows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def nested_product_category_rows(category, current_category = nil, link_to_current = true, relative_depth = 0)
                if category.present? && category.children.count > 0
                  ''.tap do |s|
                    category.children.ordered.each do |child|
                      s << '<tr>'
          Severity: Minor
          Found in app/helpers/shoppe/product_category_helper.rb - About 1 hr 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

          Function result_select has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Chosen.prototype.result_select = function(evt) {
                var high, item, selected_index;
          
                if (this.result_highlight) {
                  high = this.result_highlight;
          Severity: Minor
          Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 1 hr to fix

            Function set_up_html has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Chosen.prototype.set_up_html = function() {
                  var container_classes, container_props;
            
                  container_classes = ["chosen-container"];
                  container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
            Severity: Minor
            Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 1 hr to fix

              Method create has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def create
                    Shoppe::Order.transaction do
                      @order = Shoppe::Order.new(safe_params)
                      @order.status = 'confirming'
              
              
              Severity: Minor
              Found in app/controllers/shoppe/orders_controller.rb - About 1 hr to fix

                Function keyup_checker has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    AbstractChosen.prototype.keyup_checker = function(evt) {
                      var stroke, _ref;
                
                      stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
                      this.search_field_scale();
                Severity: Minor
                Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 1 hr to fix

                  Method attachment_preview has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def attachment_preview(attachment, options = {})
                        if attachment.present? && attachment.token.present?
                          ''.tap do |s|
                            style = if attachment.image?
                                      "style='background-image:url(#{attachment.file.thumb.url})'"
                  Severity: Minor
                  Found in app/helpers/shoppe/application_helper.rb - About 1 hr 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 delivery_service_prices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def delivery_service_prices
                        if delivery_required?
                          prices = Shoppe::DeliveryServicePrice.joins(:delivery_service).where(shoppe_delivery_services: { active: true }).order(:price).for_weight(total_weight)
                          prices = prices.select { |p| p.countries.empty? || p.country?(delivery_country) }
                          prices.sort { |x, y| (y.delivery_service.default? ? 1 : 0) <=> (x.delivery_service.default? ? 1 : 0) } # Order by truthiness
                  Severity: Minor
                  Found in app/models/shoppe/order/delivery.rb - About 1 hr 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 import has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.import(file)
                        spreadsheet = open_spreadsheet(file)
                        spreadsheet.default_sheet = spreadsheet.sheets.first
                        header = spreadsheet.row(1)
                        (2..spreadsheet.last_row).each do |i|
                  Severity: Minor
                  Found in app/models/shoppe/product.rb - About 1 hr to fix

                    Function keydown_checker has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        Chosen.prototype.keydown_checker = function(evt) {
                          var stroke, _ref1;
                    
                          stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
                          this.search_field_scale();
                    Severity: Minor
                    Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 1 hr to fix

                      Method update_from_array has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.update_from_array(array)
                            existing_keys = pluck(:key)
                            index = 0
                            array.each do |hash|
                              next if hash['key'].blank?
                      Severity: Minor
                      Found in app/models/shoppe/product_attribute.rb - About 1 hr 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

                      Function add_option has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
                            if (option.nodeName.toUpperCase() === "OPTION") {
                              if (option.text !== "") {
                                if (group_position != null) {
                                  this.parsed[group_position].children += 1;
                      Severity: Minor
                      Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (searchText.length) {
                                        startpos = option.search_text.search(zregex);
                                        text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
                                        option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
                                      }
                        Severity: Major
                        Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if (results_group != null) {
                                          results_group.group_match = true;
                                        }
                          Severity: Major
                          Found in app/assets/javascripts/shoppe/chosen.jquery.js - About 45 mins to fix

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

                                def self.update_from_hash(hash)
                                  existing_settings = all.to_a
                                  hash.each do |key, value|
                                    existing = existing_settings.find { |s| s.key.to_s == key.to_s }
                                    if existing
                            Severity: Minor
                            Found in app/models/shoppe/setting.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

                            Severity
                            Category
                            Status
                            Source
                            Language