BallStateCBER/datacenter-plugin-cakephp3

View on GitHub
webroot/js/tiny_mce/plugins/media/js/media.js

Summary

Maintainability
F
5 days
Test Coverage

File media.js has 498 lines of code (exceeds 250 allowed). Consider refactoring.
Open

tinyMCEPopup.requireLangPack();

var oldWidth, oldHeight, ed, url;

if (url = tinyMCEPopup.getParam("media_external_list_url"))
Severity: Minor
Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 7 hrs to fix

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

    function init() {
        var pl = "", f, val;
        var type = "flash", fe, i;
    
        ed = tinyMCEPopup.editor;
    Severity: Major
    Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 5 hrs to fix

      Function generatePreview has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

      function generatePreview(c) {
          var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
      
          p.innerHTML = '<!-- x --->';
      
      
      Severity: Minor
      Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 4 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 serializeParameters has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function serializeParameters() {
          var d = document, f = d.forms[0], s = '';
      
          switch (f.media_type.options[f.media_type.selectedIndex].value) {
              case "flash":
      Severity: Major
      Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 3 hrs to fix

        Function generatePreview has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function generatePreview(c) {
            var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
        
            p.innerHTML = '<!-- x --->';
        
        
        Severity: Major
        Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 3 hrs to fix

          Function insertMedia has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function insertMedia() {
              var fe, f = document.forms[0], h;
          
              tinyMCEPopup.restoreSelection();
          
          
          Severity: Major
          Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 2 hrs to fix

            Function insertMedia has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            function insertMedia() {
                var fe, f = document.forms[0], h;
            
                tinyMCEPopup.restoreSelection();
            
            
            Severity: Minor
            Found in webroot/js/tiny_mce/plugins/media/js/media.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 init has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            function init() {
                var pl = "", f, val;
                var type = "flash", fe, i;
            
                ed = tinyMCEPopup.editor;
            Severity: Minor
            Found in webroot/js/tiny_mce/plugins/media/js/media.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 getType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function getType(v) {
                var fo, i, c, el, x, f = document.forms[0];
            
                fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';');
            
            
            Severity: Minor
            Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 45 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 getBool has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function getBool(p, n, d, tv, fv) {
            Severity: Minor
            Found in webroot/js/tiny_mce/plugins/media/js/media.js - About 35 mins to fix

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

                      switch (ed.dom.getAttrib(fe, 'class')) {
                          case 'mceItemFlash':
                              type = 'flash';
                              break;
              
              
              Severity: Major
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 1 hr to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 233..257

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

              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

                      switch (f.media_type.options[f.media_type.selectedIndex].value) {
                          case "flash":
                              h += ' class="mceItemFlash"';
                              break;
              
              
              Severity: Major
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 1 hr to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 21..45

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

              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<tinyMCEMediaList.length; i++)
                          html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
              Severity: Major
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 1 hr to fix
              webroot/js/tiny_mce/plugins/advlink/js/advlink.js on lines 488..489

              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

                      fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : '');
              Severity: Major
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 1 hr to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 227..227

              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

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

                      fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : '');
              Severity: Major
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 1 hr to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 228..228

              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

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

                  if (html == "")
                      document.getElementById("linklistrow").style.display = 'none';
                  else
                      document.getElementById("linklistcontainer").innerHTML = html;
              Severity: Minor
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 55 mins to fix
              webroot/js/tiny_mce/plugins/advlink/js/advlink.js on lines 39..42

              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

                          } else if (c == 'height' && oldHeight != 0) {
                              hp = nh / oldHeight;
                              nw = Math.round(hp * nw);
                              f.width.value = nw;
                          }
              Severity: Minor
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 40 mins to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 531..539

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

              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 (c == 'width' && oldWidth != 0) {
                              wp = nw / oldWidth;
                              nh = Math.round(wp * nh);
                              f.height.value = nh;
                          } else if (c == 'height' && oldHeight != 0) {
              Severity: Minor
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 40 mins to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 535..539

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

              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 ((val = ed.dom.getAttrib(fe, "height")) != "")
                          pl.height = f.height.value = val;
              Severity: Minor
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 40 mins to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 161..162

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

              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 ((val = ed.dom.getAttrib(fe, "width")) != "")
                          pl.width = f.width.value = val;
              Severity: Minor
              Found in webroot/js/tiny_mce/plugins/media/js/media.js and 1 other location - About 40 mins to fix
              webroot/js/tiny_mce/plugins/media/js/media.js on lines 164..165

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

              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