otwcode/otwarchive

View on GitHub
public/javascripts/jquery.tokeninput.js

Summary

Maintainability
F
6 days
Test Coverage

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

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

Severity: Major
Found in public/javascripts/jquery.tokeninput.js - About 2 days to fix

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

    /*
     * jQuery Plugin: Tokenizing Autocomplete Text Entry
     * Version 1.4.2
     *
     * Copyright (c) 2009 James Smith (http://loopj.com)
    Severity: Major
    Found in public/javascripts/jquery.tokeninput.js - About 1 day to fix

      Function ajax_search has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function ajax_search(query) {
              // Extract exisiting get params
              var ajax_params = {};
              ajax_params.data = {};
              if(settings.url.indexOf("?") > -1) {
      Severity: Minor
      Found in public/javascripts/jquery.tokeninput.js - About 1 hr to fix

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

            function populate_dropdown (query, results) {
                if(results && results.length) {
                    dropdown.empty();
                    var dropdown_ul = $("<ul role=\"listbox\" aria-activedescendant=\"ui-active-menuitem\">")
                        .appendTo(dropdown)
        Severity: Minor
        Found in public/javascripts/jquery.tokeninput.js - About 1 hr to fix

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

              function add_token (item) {
                  var li_data;
                  if ($.type(item) === "string"){
                      li_data = {id: item, name: item};
                  } else {
          Severity: Minor
          Found in public/javascripts/jquery.tokeninput.js - About 1 hr to fix

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

                function insert_token(id, value) {
                    if(value.indexOf(settings.tokenDelimiter) >= 0){
                        $.each(value.split(settings.tokenDelimiter), function (index, subvalue) {
                            insert_token(subvalue, subvalue);
                        });
            Severity: Minor
            Found in public/javascripts/jquery.tokeninput.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                          if(selected_dropdown_item) {
                                              deselect_dropdown_item($(selected_dropdown_item));
                                          }
              Severity: Major
              Found in public/javascripts/jquery.tokeninput.js - About 45 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return false;
                Severity: Major
                Found in public/javascripts/jquery.tokeninput.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                    return true;
                  Severity: Major
                  Found in public/javascripts/jquery.tokeninput.js - About 30 mins to fix

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

                        var token_list = $("<ul />") // was role=\"listbox\" aria-activedescendant=\"ui-active-menuitem\"
                            .addClass(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 public/javascripts/jquery.tokeninput.js and 1 other location - About 1 hr to fix
                    public/javascripts/jquery.tokeninput.js on lines 390..417

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

                    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

                                        $.each(input_box.val().split(settings.tokenDelimiter), function(index, item) {
                                          add_token($.trim(item));
                                        });
                    Severity: Major
                    Found in public/javascripts/jquery.tokeninput.js and 1 other location - About 1 hr to fix
                    public/javascripts/jquery.tokeninput.js on lines 366..368

                    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

                                $.each(input_box.val().split(settings.tokenDelimiter), function(index, item) {
                                  add_token($.trim(item));
                                });
                    Severity: Major
                    Found in public/javascripts/jquery.tokeninput.js and 1 other location - About 1 hr to fix
                    public/javascripts/jquery.tokeninput.js on lines 336..338

                    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 (event.keyCode === KEY.TAB && settings.tokenLimit && settings.tokenLimit === token_count) {
                                            break;
                                        } else {
                                            return false;
                                        }
                    Severity: Minor
                    Found in public/javascripts/jquery.tokeninput.js and 1 other location - About 35 mins to fix
                    public/javascripts/jquery.tokeninput.js on lines 329..333

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

                    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 (event.keyCode === KEY.TAB && settings.tokenLimit && settings.tokenLimit === token_count) {
                                            break;
                                        } else {
                                            return false;
                                        }
                    Severity: Minor
                    Found in public/javascripts/jquery.tokeninput.js and 1 other location - About 35 mins to fix
                    public/javascripts/jquery.tokeninput.js on lines 340..344

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

                    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