archivesspace/archivesspace

View on GitHub
frontend/app/assets/javascripts/jquery.tokeninput.js

Summary

Maintainability
F
1 wk
Test Coverage

Function TokenList has 744 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.TokenList = function (input, url_or_data, settings) {
    //
    // Initialization
    //

Severity: Major
Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 3 days to fix

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

    /*
     * jQuery Plugin: Tokenizing Autocomplete Text Entry
     * Version 1.6.0
     *
     * Copyright (c) 2009 James Smith (http://loopj.com)
    Severity: Major
    Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 2 days to fix

      Function run_search has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function run_search(query) {
            var cache_key = query + computeURL();
            var cached_results = cache.get(cache_key);
            if (cached_results) {
              if ($.isFunction($(input).data('settings').onCachedResult)) {
      Severity: Major
      Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 3 hrs to fix

        Function populate_dropdown has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function populate_dropdown(query, results) {
              if (results && results.length) {
                dropdown.empty();
                var dropdown_label = dropdown_parent[0].nextSibling.id + '_label';
                var ul_id = dropdown_parent[0].nextSibling.id + '_listbox';
        Severity: Major
        Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 2 hrs to fix

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

              function insert_token(item) {
                var $this_token = $($(input).data('settings').tokenFormatter(item));
                var readonly = item.readonly === true ? true : false;
          
                if (readonly)
          Severity: Minor
          Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 1 hr to fix

            Function add_token has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function add_token(item) {
                  var callback = $(input).data('settings').onAdd;
            
                  // See if the token already exists and select it if we don't want duplicates
                  if (token_count > 0 && $(input).data('settings').preventDuplicates) {
            Severity: Minor
            Found in frontend/app/assets/javascripts/jquery.tokeninput.js - About 1 hr to fix

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

                  var token_list = $('<ul />')
                    .addClass($(input).data('settings').classes.tokenList)
                    .click(function (event) {
                      var li = $(event.target).closest('li');
                      if (li && li.get(0) && $.data(li.get(0), 'tokeninput')) {
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 2 hrs to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 440..467

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

              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

                  function show_dropdown_searching() {
                    if ($(input).data('settings').searchingText) {
                      dropdown.html(
                        '<p>' + escapeHTML($(input).data('settings').searchingText) + '</p>'
                      );
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 2 hrs to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 891..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 76.

              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

                  function show_dropdown_hint() {
                    if ($(input).data('settings').hintText) {
                      dropdown.html(
                        '<p>' + escapeHTML($(input).data('settings').hintText) + '</p>'
                      );
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 2 hrs to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 882..889

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

              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 3 locations. Consider refactoring.
              Open

                      if ($.isFunction($(input).data('settings').onFreeTaggingAdd)) {
                        token = $(input)
                          .data('settings')
                          .onFreeTaggingAdd.call(hidden_input, token);
                      }
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 1 hr to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1060..1064
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1139..1143

              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 3 locations. Consider refactoring.
              Open

                      if ($.isFunction($(input).data('settings').onCachedResult)) {
                        cached_results = $(input)
                          .data('settings')
                          .onCachedResult.call(hidden_input, cached_results);
                      }
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 1 hr to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 644..648
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1139..1143

              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 3 locations. Consider refactoring.
              Open

                        if ($.isFunction($(input).data('settings').onResult)) {
                          results = $(input)
                            .data('settings')
                            .onResult.call(hidden_input, results);
                        }
              Severity: Major
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 1 hr to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 644..648
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1060..1064

              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

                  tokenFormatter: function (item) {
                    var string = item[this.propertyToSearch];
                    return (
                      '<li><p>' +
                      (this.enableHTML ? string : _escapeHTML(string)) +
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 50 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 39..44

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

              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

                  resultsFormatter: function (item) {
                    var string = item[this.propertyToSearch];
                    return (
                      '<li>' + (this.enableHTML ? string : _escapeHTML(string)) + '</li>'
                    );
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 50 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 46..53

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

              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 3 locations. Consider refactoring.
              Open

                    if (
                      $(input).data('settings').tokenLimit !== null &&
                      token_count >= $(input).data('settings').tokenLimit
                    ) {
                      input_box.hide();
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 35 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 607..614
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 736..742

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

              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 3 locations. Consider refactoring.
              Open

                    if (
                      $(input).data('settings').tokenLimit !== null &&
                      token_count >= $(input).data('settings').tokenLimit
                    ) {
                      input_box.hide();
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 35 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 700..706
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 736..742

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

              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

                  var input_token = $('<li />')
                    .addClass($(input).data('settings').classes.inputToken)
                    .appendTo(token_list)
                    .append(input_box);
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 35 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 488..491

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

              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

                  var dropdown = $('<div>')
                    .addClass($(input).data('settings').classes.dropdown)
                    .appendTo(dropdown_parent)
                    .hide();
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 35 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 471..474

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

              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 3 locations. Consider refactoring.
              Open

                    if (
                      $(input).data('settings').tokenLimit === null ||
                      token_count < $(input).data('settings').tokenLimit
                    ) {
                      insert_token(item);
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 2 other locations - About 35 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 607..614
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 700..706

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

              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

                            cache.add(
                              cache_key,
                              $(input).data('settings').jsonContainer
                                ? results[$(input).data('settings').jsonContainer]
                                : results
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 30 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1114..1119

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

              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

                            populate_dropdown(
                              query,
                              $(input).data('settings').jsonContainer
                                ? results[$(input).data('settings').jsonContainer]
                                : results
              Severity: Minor
              Found in frontend/app/assets/javascripts/jquery.tokeninput.js and 1 other location - About 30 mins to fix
              frontend/app/assets/javascripts/jquery.tokeninput.js on lines 1099..1104

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

              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