mangroveorg/datawinners

View on GitHub
datawinners/media/javascript/jquery-textntags/jquery-textntags.js

Summary

Maintainability
F
5 days
Test Coverage

Function TextNTags has 534 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var TextNTags = function (editor) {
        var settings = null, templates;
        var elContainer, elEditor, elBeautifier, elTagList, elTagListItemActive;
        var tagsCollection;
        var currentTriggerChar, currentDataQuery;
Severity: Major
Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 2 days to fix

    File jquery-textntags.js has 617 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Text'N'Tags (textntags)
     * Version 0.1.2
     * Written by: Daniel Zahariev
     *
    Severity: Major
    Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 1 day to fix

      Function onEditorKeyDown has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function onEditorKeyDown (e) {
                  var keys = KEY, // store in local var for faster lookup
                      sStart = getInputSelection(elEditor[0]).start,
                      sEnd = getInputSelection(elEditor[0]).end,
      //                sStart = elEditor[0].selectionStart,
      Severity: Major
      Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 3 hrs to fix

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

                function parseTaggedText (tagged_text) {
                    if (_.isString(tagged_text) == false) {
                        return null;
                    } 
                    var plain_text = '' + tagged_text, tagsColl = [], triggers = settings.triggers;
        Severity: Minor
        Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 1 hr to fix

          Function getInputSelection has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function getInputSelection(el) {
                      var start = 0, end = 0, normalizedValue, range,
                          textInputRange, len, endRange;
          
                      if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
          Severity: Minor
          Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 1 hr to fix

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

                    function onEditorInput (e) {
                        var selectionStartFix = $.browser.webkit ? 0 : -1;
                        if (editorKeyCode != KEY.BACKSPACE && editorKeyCode != KEY['DELETE']) {
                            if (editorSelectionLength > 0) {
                                // delete of selection occured
            Severity: Minor
            Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 1 hr to fix

              Function populateTagList has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function populateTagList (query, triggerChar, results) {
                          var trigger = settings.triggers[triggerChar];
                          
                          if (trigger.uniqueTags) {
                              // Filter items that has already been mentioned
              Severity: Minor
              Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 1 hr to fix

                Avoid too many return statements within this function.
                Open

                            return true;
                Severity: Major
                Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                          return false;
                  Severity: Major
                  Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return false;
                    Severity: Major
                    Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return true;
                      Severity: Major
                      Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return true;
                        Severity: Major
                        Found in datawinners/media/javascript/jquery-textntags/jquery-textntags.js - About 30 mins to fix

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

                                              } else {
                                                  if (elTagListItemActive && elTagListItemActive.length) {
                                                      elCurrentTagListItem = elTagListItemActive.prev();
                                                  } else {
                                                      elCurrentTagListItem = elTagList.find('li').last();
                          datawinners/media/javascript/jquery-textntags/jquery-textntags.js on lines 368..374

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

                          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 (e.keyCode == keys.DOWN) {
                                                  if (elTagListItemActive && elTagListItemActive.length) {
                                                      elCurrentTagListItem = elTagListItemActive.next();
                                                  } else {
                                                      elCurrentTagListItem = elTagList.find('li').first();
                          datawinners/media/javascript/jquery-textntags/jquery-textntags.js on lines 374..380

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

                          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

                                              inRange = ((s >= start && s < end) || (e > start && e <= end) || (s < start && e > end));
                          datawinners/media/javascript/jqueryUI/jquery-ui-1.8.13.custom.min.js on lines 942..942
                          datawinners/media/javascript/jqueryUI/jquery-ui-1.8.13.custom.min.js on lines 942..943

                          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