myems-admin/js/plugins/chosen/chosen.jquery.js

Summary

Maintainability
F
5 days
Test Coverage

File chosen.jquery.js has 1109 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.1.0
Severity: Major
Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 2 days to fix

    Function register_observers has 73 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 myems-admin/js/plugins/chosen/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;
                  searchText = this.get_search_text();
      Severity: Major
      Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 2 hrs 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"));
                    if (this.inherit_select_classes && this.form_field.className) {
        Severity: Minor
        Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 1 hr to fix

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

                  Chosen.prototype.result_select = function(evt) {
                      var high, item;
                      if (this.result_highlight) {
                          high = this.result_highlight;
                          this.result_clear_highlight();
          Severity: Minor
          Found in myems-admin/js/plugins/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 myems-admin/js/plugins/chosen/chosen.jquery.js - About 1 hr to fix

              Function result_add_option has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      AbstractChosen.prototype.result_add_option = function(option) {
                          var classes, option_el;
                          if (!option.search_match) {
                              return '';
                          }
              Severity: Minor
              Found in myems-admin/js/plugins/chosen/chosen.jquery.js - 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();
                            if (stroke !== 8 && this.pending_backstroke) {
                Severity: Minor
                Found in myems-admin/js/plugins/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.toUpperCase() === "OPTION") {
                                  if (option.text !== "") {
                                      if (group_position != null) {
                                          this.parsed[group_position].children += 1;
                  Severity: Minor
                  Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (results_group != null) {
                                                    results_group.group_match = true;
                                                }
                    Severity: Major
                    Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 45 mins 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 myems-admin/js/plugins/chosen/chosen.jquery.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
                                                    option.search_match = true;
                                                }
                        Severity: Major
                        Found in myems-admin/js/plugins/chosen/chosen.jquery.js - About 45 mins to fix

                          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 myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 590..593

                          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

                                      } else {
                                          this.search_container = this.container.find('div.chosen-search').first();
                                          this.selected_item = this.container.find('.chosen-single').first();
                                      }
                          Severity: Major
                          Found in myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 587..590

                          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

                          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 myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 911..911

                          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 myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 901..901

                          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 myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 1141..1146

                          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 myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 824..829

                          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

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

                                          if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
                                              this.form_field_jq.trigger("chosen:maxselected", {
                                                  chosen: this
                                              });
                                              return false;
                          Severity: Major
                          Found in myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 832..837

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

                          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

                                      if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
                                          this.form_field_jq.trigger("chosen:maxselected", {
                                              chosen: this
                                          });
                                          return false;
                          Severity: Major
                          Found in myems-admin/js/plugins/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
                          myems-admin/js/plugins/chosen/chosen.jquery.js on lines 985..990

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

                          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