insideout10/wordlift-plugin-js

View on GitHub
app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js

Summary

Maintainability
F
5 days
Test Coverage

File advlink.js has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Functions for the advlink plugin popup */

tinyMCEPopup.requireLangPack();

var templates = {
Severity: Minor
Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 5 hrs to fix

    Function init has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function init() {
        tinyMCEPopup.resizeToInnerSize();
    
        var formObj = document.forms[0];
        var inst = tinyMCEPopup.editor;
    Severity: Major
    Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 3 hrs to fix

      Function init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      function init() {
          tinyMCEPopup.resizeToInnerSize();
      
          var formObj = document.forms[0];
          var inst = tinyMCEPopup.editor;
      Severity: Minor
      Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function buildOnClick has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildOnClick() {
          var formObj = document.forms[0];
      
          if (!formObj.ispopup.checked) {
              formObj.onclick.value = "";
      Severity: Minor
      Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

      function buildOnClick() {
          var formObj = document.forms[0];
      
          if (!formObj.ispopup.checked) {
              formObj.onclick.value = "";
      Severity: Minor
      Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

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

        function setAllAttribs(elm) {
            var formObj = document.forms[0];
            var href = formObj.href.value.replace(/ /g, '%20');
            var target = getSelectValue(formObj, 'targetlist');
        
        Severity: Minor
        Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

          Function parseLink has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function parseLink(link) {
              link = link.replace(new RegExp(''', 'g'), "'");
          
              var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
          
          Severity: Minor
          Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          function parseWindowOpen(onclick) {
              var formObj = document.forms[0];
          
              // Preprocess center code
              if (onclick.indexOf('return false;') != -1) {
          Severity: Minor
          Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

            Function insertAction has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function insertAction() {
                var inst = tinyMCEPopup.editor;
                var elm, elementArray, i;
            
                elm = inst.selection.getNode();
            Severity: Minor
            Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

              Function parseLink has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function parseLink(link) {
                  link = link.replace(new RegExp(''', 'g'), "'");
              
                  var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
              
              Severity: Minor
              Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 1 hr to fix

                Function getAnchorListHTML has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function getAnchorListHTML(id, target) {
                    var ed = tinyMCEPopup.editor, nodes = ed.dom.select('a'), name, i, len, html = "";
                
                    for (i=0, len=nodes.length; i<len; i++) {
                        if ((name = ed.dom.getAttrib(nodes[i], "name")) != "")
                Severity: Minor
                Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function parseWindowOpen has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function parseWindowOpen(onclick) {
                    var formObj = document.forms[0];
                
                    // Preprocess center code
                    if (onclick.indexOf('return false;') != -1) {
                Severity: Minor
                Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 25 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function insertAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function insertAction() {
                    var inst = tinyMCEPopup.editor;
                    var elm, elementArray, i;
                
                    elm = inst.selection.getNode();
                Severity: Minor
                Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js - About 25 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                function checkPrefix(n) {
                    if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
                        n.value = 'mailto:' + n.value;
                
                    if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
                app/lib/tinymce/jscripts/tiny_mce/themes/advanced/js/link.js on lines 95..101

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

                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 (elm.childNodes.length != 1 || elm.firstChild.nodeName != 'IMG') {
                        inst.focus();
                        inst.selection.select(elm);
                        inst.selection.collapse(0);
                        tinyMCEPopup.storeSelection();
                app/lib/tinymce/jscripts/tiny_mce/themes/advanced/js/link.js on lines 84..89

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

                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 (formObj.popupleft.value != "") {
                        if (formObj.popupleft.value != "c")
                            onclick += "left=" + formObj.popupleft.value + ",";
                        else
                            onclick += "left='+(screen.availWidth/2-" + (formObj.popupwidth.value/2) + ")+',";
                app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js on lines 333..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 86.

                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 (formObj.popuptop.value != "") {
                        if (formObj.popuptop.value != "c")
                            onclick += "top=" + formObj.popuptop.value + ",";
                        else
                            onclick += "top='+(screen.availHeight/2-" + (formObj.popupheight.value/2) + ")+',";
                app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js on lines 326..331

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

                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 (!document.forms[0].href.value) {
                        i = inst.selection.getBookmark();
                        inst.dom.remove(elm, 1);
                        inst.selection.moveToBookmark(i);
                        tinyMCEPopup.execCommand("mceEndUndoLevel");
                app/lib/tinymce/jscripts/tiny_mce/themes/advanced/js/link.js on lines 41..48

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

                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

                    for (var i=0; i<tinyMCELinkList.length; i++)
                        html += '<option value="' + tinyMCELinkList[i][1] + '">' + tinyMCELinkList[i][0] + '</option>';
                app/lib/tinymce/jscripts/tiny_mce/plugins/media/js/media.js on lines 461..462

                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

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

                function preinit() {
                    var url;
                
                    if (url = tinyMCEPopup.getParam("external_link_list_url"))
                        document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
                app/lib/tinymce/jscripts/tiny_mce/themes/advanced/js/link.js on lines 4..9

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

                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 (html == "")
                        document.getElementById("anchorlistrow").style.display = 'none';
                    else
                        document.getElementById("anchorlistcontainer").innerHTML = html;
                Severity: Minor
                Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js and 1 other location - About 55 mins to fix
                app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js on lines 37..40

                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 (html == "")
                        document.getElementById("linklisthrefrow").style.display = 'none';
                    else
                        document.getElementById("linklisthrefcontainer").innerHTML = html;
                Severity: Minor
                Found in app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js and 1 other location - About 55 mins to fix
                app/lib/tinymce/jscripts/tiny_mce/plugins/advlink/js/advlink.js on lines 44..47

                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