tryshoppe/core

View on GitHub

Showing 40 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      } else {
                        this.search_container = this.container.find('div.chosen-search').first();
                        this.selected_item = this.container.find('.chosen-single').first();
                      }
                Severity: Major
                Found in app/assets/javascripts/shoppe/chosen.jquery.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/shoppe/chosen.jquery.js on lines 544..547

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 63.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      if (this.is_multiple) {
                        this.search_choices = this.container.find('ul.chosen-choices').first();
                        this.search_container = this.container.find('li.search-field').first();
                      } else {
                Severity: Major
                Found in app/assets/javascripts/shoppe/chosen.jquery.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/shoppe/chosen.jquery.js on lines 547..550

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 63.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                        target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
                  Severity: Major
                  Found in app/assets/javascripts/shoppe/chosen.jquery.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/shoppe/chosen.jquery.js on lines 853..853

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 60.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                        target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
                  Severity: Major
                  Found in app/assets/javascripts/shoppe/chosen.jquery.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/shoppe/chosen.jquery.js on lines 842..842

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 60.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          Chosen.prototype.result_clear_highlight = function() {
                            if (this.result_highlight) {
                              this.result_highlight.removeClass("highlighted");
                            }
                            return this.result_highlight = null;
                      Severity: Major
                      Found in app/assets/javascripts/shoppe/chosen.jquery.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/shoppe/chosen.jquery.js on lines 1094..1099

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 57.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language