insideout10/wordlift-plugin-js

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

Summary

Maintainability
F
3 days
Test Coverage

Function insertTable has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

function insertTable() {
    var formObj = document.forms[0];
    var inst = tinyMCEPopup.editor, dom = inst.dom;
    var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className, caption, frame, rules;
    var html = '', capEl, elm;
Severity: Minor
Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js - About 1 day 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 insertTable has 186 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function insertTable() {
    var formObj = document.forms[0];
    var inst = tinyMCEPopup.editor, dom = inst.dom;
    var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className, caption, frame, rules;
    var html = '', capEl, elm;
Severity: Major
Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js - About 7 hrs to fix

    File table.js has 360 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    tinyMCEPopup.requireLangPack();
    
    var action, orgTableWidth, orgTableHeight, dom = tinyMCEPopup.editor.dom;
    
    function insertTable() {
    Severity: Minor
    Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js - About 4 hrs to fix

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

      function init() {
          tinyMCEPopup.resizeToInnerSize();
      
          document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
          document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
      Severity: Major
      Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js - About 3 hrs to fix

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

        function init() {
            tinyMCEPopup.resizeToInnerSize();
        
            document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
            document.getElementById('backgroundimagebrowsercontainer').innerHTML = getBrowserHTML('backgroundimagebrowser','backgroundimage','image','table');
        Severity: Minor
        Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.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

        Avoid too many return statements within this function.
        Open

                return true;
        Severity: Major
        Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js - About 30 mins to fix

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

          function changedBorder() {
              var formObj = document.forms[0];
              var st = dom.parseStyle(formObj.style.value);
          
              // Update border width if the element has a color
          Severity: Minor
          Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.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 3 locations. Consider refactoring.
          Open

              if (st['background-image'])
                  formObj.backgroundimage.value = st['background-image'].replace(new RegExp("url\\(['\"]?([^'\"]*)['\"]?\\)", 'gi'), "$1");
              else
                  formObj.backgroundimage.value = '';
          app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/cell.js on lines 297..300
          app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/row.js on lines 202..205

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

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

              if (!AutoValidator.validate(formObj)) {
                  tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
                  return false;
              }
          Severity: Major
          Found in app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/table.js and 2 other locations - About 50 mins to fix
          app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/cell.js on lines 66..69
          app/lib/tinymce/jscripts/tiny_mce/plugins/table/js/row.js on lines 60..63

          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

          There are no issues that match your filters.

          Category
          Status