ImpressCMS/impresscms

View on GitHub
htdocs/modules/system/admin/images/js/imanager.js

Summary

Maintainability
D
2 days
Test Coverage

Function addItem has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

function addItem(itemurl, name, target, cat, url, type) {
    var win = opener;
    var campo = win.document.getElementById(target);
    var opcoes = win.document.getElementById('img_cat_'+cat);
    var imagem = win.document.getElementById(target+'_img');
Severity: Minor
Found in htdocs/modules/system/admin/images/js/imanager.js - About 3 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 selFilter has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function selFilter(id,value){
    var div_arg1 = xoopsGetElementById(id+'_arg1');
    var div_arg2 = xoopsGetElementById(id+'_arg2');
    var div_arg3 = xoopsGetElementById(id+'_arg3');
    
Severity: Minor
Found in htdocs/modules/system/admin/images/js/imanager.js - About 1 hr to fix

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

    function selFilter(id,value){
        var div_arg1 = xoopsGetElementById(id+'_arg1');
        var div_arg2 = xoopsGetElementById(id+'_arg2');
        var div_arg3 = xoopsGetElementById(id+'_arg3');
        
    Severity: Minor
    Found in htdocs/modules/system/admin/images/js/imanager.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 addItem has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addItem(itemurl, name, target, cat, url, type) {
        var win = opener;
        var campo = win.document.getElementById(target);
        var opcoes = win.document.getElementById('img_cat_'+cat);
        var imagem = win.document.getElementById(target+'_img');
    Severity: Minor
    Found in htdocs/modules/system/admin/images/js/imanager.js - About 1 hr to fix

      Function appendCode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function appendCode(addCode,target) {
          var targetDom = window.opener.xoopsGetElementById(target);
          if (targetDom.createTextRange && targetDom.caretPos){
              var caretPos = targetDom.caretPos;
              caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)
      Severity: Minor
      Found in htdocs/modules/system/admin/images/js/imanager.js - About 55 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 addItem has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function addItem(itemurl, name, target, cat, url, type) {
      Severity: Minor
      Found in htdocs/modules/system/admin/images/js/imanager.js - About 45 mins to fix

        Function filter_preview has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function filter_preview(id,xurl,img,width,height){
        Severity: Minor
        Found in htdocs/modules/system/admin/images/js/imanager.js - About 35 mins to fix

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

          function filter_preview(id,xurl,img,width,height){
              var filter = xoopsGetElementById('filter'+id).value;
              var arg1 = xoopsGetElementById(id+'arg1').value;
              var arg2 = xoopsGetElementById(id+'arg2').value;
              var arg3 = xoopsGetElementById(id+'arg3').value;
          Severity: Minor
          Found in htdocs/modules/system/admin/images/js/imanager.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

              if (targetDom.createTextRange && targetDom.caretPos){
                  var caretPos = targetDom.caretPos;
                  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)
                  == ' ' ? addCode + ' ' : addCode;
              } else if (targetDom.getSelection && targetDom.caretPos){
          Severity: Major
          Found in htdocs/modules/system/admin/images/js/imanager.js and 1 other location - About 7 hrs to fix
          htdocs/include/xoops.js on lines 191..201

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

          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 (i=0; i<divs.length;i++){
                  if (/opt_divs/.test(divs[i].className)){
                      divs[i].style.display = 'none';
                  }
              }
          Severity: Major
          Found in htdocs/modules/system/admin/images/js/imanager.js and 1 other location - About 1 hr to fix
          htdocs/include/xoops.js on lines 515..519

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

          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 (i=0;i<=Filters.length-1;i++){
                      if (Filters[i].value == value){
                          var filter = Filters[i];
                      }
                  }
          Severity: Major
          Found in htdocs/modules/system/admin/images/js/imanager.js and 1 other location - About 1 hr to fix
          htdocs/modules/system/admin/images/js/imanager.js on lines 139..143

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

          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 (i=0;i<=Filters.length-1;i++){
                  if (Filters[i].value == filter){
                      var filterdata = Filters[i];
                  }
              }
          Severity: Major
          Found in htdocs/modules/system/admin/images/js/imanager.js and 1 other location - About 1 hr to fix
          htdocs/modules/system/admin/images/js/imanager.js on lines 112..116

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

          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

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          Unexpected trailing spaces found.
          Open

              

          There are no issues that match your filters.

          Category
          Status