drhenner/ror_ecommerce

View on GitHub
app/assets/javascripts/chosen/chosen.jquery.js

Summary

Maintainability
F
4 days
Test Coverage

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

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

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

        Chosen.prototype.winnow_results = function() {
          var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
          this.no_results_clear();
          results = 0;
          searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
    Severity: Major
    Found in app/assets/javascripts/chosen/chosen.jquery.js - About 2 hrs to fix

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

          Chosen.prototype.set_up_html = function() {
            var container_div, dd_top, dd_width, sf_width;
            this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
            this.container_id += "_chzn";
            this.f_width = this.form_field_jq.outerWidth() + 60;
      Severity: Minor
      Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

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

            Chosen.prototype.register_observers = function() {
              this.container.mousedown(__bind(function(evt) {
                return this.container_mousedown(evt);
              }, this));
              this.container.mouseup(__bind(function(evt) {
        Severity: Minor
        Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

          Function results_build has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Chosen.prototype.results_build = function() {
                var content, data, _i, _len, _ref;
                this.parsing = true;
                this.results_data = root.SelectParser.select_to_array(this.form_field);
                if (this.is_multiple && this.choices > 0) {
          Severity: Minor
          Found in app/assets/javascripts/chosen/chosen.jquery.js - 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();
                  switch (stroke) {
            Severity: Minor
            Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

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

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

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

                    Chosen.prototype.search_field_scale = function() {
                      var dd_top, div, h, style, style_block, styles, w, _i, _len;
                      if (this.is_multiple) {
                        h = 0;
                        w = 0;
                Severity: Minor
                Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

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

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

                    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 === "OPTION") {
                            if (option.text !== "") {
                              if (group_position != null) {
                                this.parsed[group_position].children += 1;
                    Severity: Minor
                    Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

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

                        Avoid deeply nested control flow statements.
                        Open

                                      if (option.group_array_index != null) {
                                        $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
                                      }
                        Severity: Major
                        Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if (parts.length) {
                                          for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
                                            part = parts[_j];
                                            if (regex.test(part)) {
                                              found = true;
                          Severity: Major
                          Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
                                            this.result_clear_highlight();
                                          }
                            Severity: Major
                            Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                              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/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 567..567

                              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/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 575..575

                              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

                              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/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 818..823

                              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

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

                                  Chosen.prototype.clear_backstroke = function() {
                                    if (this.pending_backstroke) {
                                      this.pending_backstroke.removeClass("search-choice-focus");
                                    }
                                    return this.pending_backstroke = null;
                              Severity: Major
                              Found in app/assets/javascripts/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 509..514

                              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

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

                                    if (!this.is_multiple && !this.active_field) {
                                      this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
                                      this.selected_item.attr("tabindex", -1);
                                    }
                              Severity: Minor
                              Found in app/assets/javascripts/chosen/chosen.jquery.js and 1 other location - About 45 mins to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 415..418

                              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 50.

                              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.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
                                      this.search_field.attr("tabindex", -1);
                                    }
                              Severity: Minor
                              Found in app/assets/javascripts/chosen/chosen.jquery.js and 1 other location - About 45 mins to fix
                              app/assets/javascripts/chosen/chosen.jquery.js on lines 428..431

                              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 50.

                              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

                              There are no issues that match your filters.

                              Category
                              Status