ncbo/bioportal_web_ui

View on GitHub
public/widgets/jquery.ncbo.autocomplete.js

Summary

Maintainability
F
3 days
Test Coverage

Function NCBOAutocomplete has 268 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.NCBOAutocomplete = function(settings) {
    var defaults = {
        url: '',
        data: [],
        minCharacters: 1,
Severity: Major
Found in public/widgets/jquery.ncbo.autocomplete.js - About 1 day to fix

    File jquery.ncbo.autocomplete.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*jshint curly: true, eqeqeq: true, undef: true, devel: true, browser: true */
    /*global jQuery */
    
    /**
     * Turn a text box into an auto suggest box which search's and
    Severity: Minor
    Found in public/widgets/jquery.ncbo.autocomplete.js - About 2 hrs to fix

      Function runSuggest has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function runSuggest(e) {
              var search = function(searchData) {
                if (this.value.length < settings.minCharacters) {
                  clearAndHideResults();
                  return false;
      Severity: Major
      Found in public/widgets/jquery.ncbo.autocomplete.js - About 2 hrs to fix

        Function keyListener has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function keyListener(e) {
                switch (e.keyCode) {
                  case 9:
                  case 27:
                  case 16:
        Severity: Minor
        Found in public/widgets/jquery.ncbo.autocomplete.js - About 1 hr to fix

          Function buildResults has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                function buildResults(resultObjects, filterTxt) {
                  filterTxt = '(' + filterTxt + ')';
          
                  var bOddRow = true, i, iFound = 0,
                    filterPatt = settings.caseSensitive ? new RegExp(filterTxt, 'g') : new RegExp(filterTxt, 'ig');
          Severity: Minor
          Found in public/widgets/jquery.ncbo.autocomplete.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                        return false;
            Severity: Major
            Found in public/widgets/jquery.ncbo.autocomplete.js - About 30 mins to fix

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

                        case 40: // down key
                          // only fire on keydown
                          if (e.type == "keyup") {
                            return false;
                          }
              Severity: Major
              Found in public/widgets/jquery.ncbo.autocomplete.js and 1 other location - About 3 hrs to fix
              public/widgets/jquery.ncbo.autocomplete.js on lines 348..365

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

              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

                        case 38: // up key
                          // only fire on keydown
                          if (e.type == "keyup") {
                            return false;
                          }
              Severity: Major
              Found in public/widgets/jquery.ncbo.autocomplete.js and 1 other location - About 3 hrs to fix
              public/widgets/jquery.ncbo.autocomplete.js on lines 330..347

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

              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 (typeof resultObjects[i].image === 'string') {
                          $('>a', item).prepend('<img src="' + resultObjects[i].image + '" />');
                        }
              Severity: Minor
              Found in public/widgets/jquery.ncbo.autocomplete.js and 1 other location - About 55 mins to fix
              public/widgets/jquery.ncbo.autocomplete.js on lines 195..197

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

              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 (typeof resultObjects[i].extra === 'string') {
                          $('>a', item).append('<small>' + resultObjects[i].extra + '</small>');
                        }
              Severity: Minor
              Found in public/widgets/jquery.ncbo.autocomplete.js and 1 other location - About 55 mins to fix
              public/widgets/jquery.ncbo.autocomplete.js on lines 191..193

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

              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