I-de-ya/ideyabox

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

Summary

Maintainability
F
4 days
Test Coverage

File chosen.jquery.js has 911 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.8
// Full source at https://github.com/harvesthq/chosen
Severity: Major
Found in app/assets/javascripts/chosen.jquery.js - About 2 days to fix

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

        Chosen.prototype.winnow_results = function() {
          var found, option, part, parts, regex, regexAnchor, 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.jquery.js - About 2 hrs to fix

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

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

        Function set_up_html has 44 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(/[^\w]/g, '_') : this.generate_field_id();
              this.container_id += "_chzn";
              this.f_width = this.form_field_jq.outerWidth();
        Severity: Minor
        Found in app/assets/javascripts/chosen.jquery.js - About 1 hr to fix

          Function results_build has 35 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.jquery.js - About 1 hr to fix

            Function result_select has 33 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.jquery.js - About 1 hr to fix

              Function keyup_checker has 29 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.jquery.js - About 1 hr to fix

                Function search_field_scale has 26 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.jquery.js - About 1 hr 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.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.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.jquery.js - About 45 mins 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.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.jquery.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/chosen.jquery.js on lines 644..644

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status