concord-consortium/rigse

View on GitHub
rails/app/assets/javascripts/chosen.proto.js

Summary

Maintainability
F
1 wk
Test Coverage

Function Chosen has 672 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  this.Chosen = (function(_super) {
    __extends(Chosen, _super);

    function Chosen() {
      _ref = Chosen.__super__.constructor.apply(this, arguments);
Severity: Major
Found in rails/app/assets/javascripts/chosen.proto.js - About 3 days to fix

    File chosen.proto.js has 1195 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.5.1
    Severity: Major
    Found in rails/app/assets/javascripts/chosen.proto.js - About 3 days to fix

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

          Chosen.prototype.register_observers = function() {
            var _this = this;
            this.container.observe("touchstart", function(evt) {
              _this.container_mousedown(evt);
              return evt.preventDefault();
      Severity: Major
      Found in rails/app/assets/javascripts/chosen.proto.js - About 3 hrs to fix

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

            AbstractChosen.prototype.winnow_results = function() {
              var escapedSearchText, option, regex, 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 rails/app/assets/javascripts/chosen.proto.js - About 2 hrs to fix

          Function set_up_html has 40 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 rails/app/assets/javascripts/chosen.proto.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 rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

              Function keydown_checker has 35 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 rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

                Function keyup_checker has 34 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 rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

                  Function result_add_option has 32 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 rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

                    Function add_option has 28 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 rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

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

                          AbstractChosen.prototype.results_option_build = function(options) {
                            var content, data, data_content, shown_results, _i, _len, _ref;
                            content = '';
                            shown_results = 0;
                            _ref = this.results_data;
                      Severity: Minor
                      Found in rails/app/assets/javascripts/chosen.proto.js - About 1 hr 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 rails/app/assets/javascripts/chosen.proto.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 rails/app/assets/javascripts/chosen.proto.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 rails/app/assets/javascripts/chosen.proto.js - About 45 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return false;
                              Severity: Major
                              Found in rails/app/assets/javascripts/chosen.proto.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return document.documentMode >= 8;
                                Severity: Major
                                Found in rails/app/assets/javascripts/chosen.proto.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return true;
                                  Severity: Major
                                  Found in rails/app/assets/javascripts/chosen.proto.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return false;
                                    Severity: Major
                                    Found in rails/app/assets/javascripts/chosen.proto.js - About 30 mins to fix

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

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

                                      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.result_clear_highlight = function() {
                                            if (this.result_highlight) {
                                              this.result_highlight.removeClassName('highlighted');
                                            }
                                            return this.result_highlight = null;
                                      Severity: Major
                                      Found in rails/app/assets/javascripts/chosen.proto.js and 1 other location - About 1 hr to fix
                                      rails/app/assets/javascripts/chosen.proto.js on lines 1223..1228

                                      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.fire("chosen:maxselected", {
                                                  chosen: this
                                                });
                                                return false;
                                      Severity: Major
                                      Found in rails/app/assets/javascripts/chosen.proto.js and 1 other location - About 1 hr to fix
                                      rails/app/assets/javascripts/chosen.proto.js on lines 893..898

                                      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.fire("chosen:maxselected", {
                                                chosen: this
                                              });
                                              return false;
                                      Severity: Major
                                      Found in rails/app/assets/javascripts/chosen.proto.js and 1 other location - About 1 hr to fix
                                      rails/app/assets/javascripts/chosen.proto.js on lines 1055..1060

                                      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

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

                                            if (this.is_multiple) {
                                              this.search_choices = this.container.down('ul.chosen-choices');
                                              this.search_container = this.container.down('li.search-field');
                                            } else {
                                      Severity: Minor
                                      Found in rails/app/assets/javascripts/chosen.proto.js and 1 other location - About 40 mins to fix
                                      rails/app/assets/javascripts/chosen.proto.js on lines 630..633

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

                                      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.down('div.chosen-search');
                                              this.selected_item = this.container.down('.chosen-single');
                                            }
                                      Severity: Minor
                                      Found in rails/app/assets/javascripts/chosen.proto.js and 1 other location - About 40 mins to fix
                                      rails/app/assets/javascripts/chosen.proto.js on lines 627..630

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

                                      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