ImpressCMS/impresscms

View on GitHub
htdocs/include/icms_rtl.js

Summary

Maintainability
F
3 days
Test Coverage

Function AdMenu has a Cognitive Complexity of 145 (exceeds 5 allowed). Consider refactoring.
Open

function AdMenu(id) { this.type = "horizontal"; this.position = { "level1": { "top": 0, "left": 0}, "levelX": { "top": 0, "left": 0}
}
this.zIndex = { "visible": 1, "hidden": -1
}
this.arrow1 = null; this.arrow2 = null; this.browser = { "ie": Boolean(document.body.currentStyle), "ie5": (navigator.appVersion.indexOf("MSIE 5.5") != -1 || navigator.appVersion.indexOf("MSIE 5.0") != -1)
Severity: Minor
Found in htdocs/include/icms_rtl.js - About 2 days 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 AdMenu has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function AdMenu(id) { this.type = "horizontal"; this.position = { "level1": { "top": 0, "left": 0}, "levelX": { "top": 0, "left": 0}
}
this.zIndex = { "visible": 1, "hidden": -1
}
this.arrow1 = null; this.arrow2 = null; this.browser = { "ie": Boolean(document.body.currentStyle), "ie5": (navigator.appVersion.indexOf("MSIE 5.5") != -1 || navigator.appVersion.indexOf("MSIE 5.0") != -1)
Severity: Major
Found in htdocs/include/icms_rtl.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

    } else if (this.type == "vertical") { box2.style.top = (box1.offsetTop + this.position.level1.top) + "px"; if (this.browser.ie5) { box2.style.left = (box1.offsetWidth + this.position.level1.left) + "px";} else { box2.style.left = (box1.offsetLeft + box1.offsetWidth + this.position.level1.Left) + "px";}
    }
    Severity: Major
    Found in htdocs/include/icms_rtl.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

      nodes[i].id = id + "-" + (tree.length - 1) + "-section"; var box1 = document.getElementById(id + "-" + (tree.length - 1)); var box2 = document.getElementById(nodes[i].id); var el = new Element(box1.id); if (el.level == 1) { if (this.type == "horizontal") { box2.style.top = (box1.offsetTop + box1.offsetHeight + this.position.level1.top) + "px"; if (this.browser.ie5) { box2.style.left = (this.position.level1.left) + "px";} else {
      /* Start open menu from right_to_left - added by stranger @ www.impresscms.ir , Script & Original hack are made by irmtfan (www.jadoogaran.org) */
      box2.style.Right = ( box1.offsetLeft + this.position.level1.left) + "px";}
      Severity: Major
      Found in htdocs/include/icms_rtl.js - About 45 mins to fix

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

        this.show = function(id) { var el = new Element(id); document.getElementById(id).className = (el.level == 1 ? "button-active" : "item-active"); if (el.level > 1 && this.arrow2) { document.getElementById(id + "-arrow").src = this.arrow2;}
        Severity: Minor
        Found in htdocs/include/icms_rtl.js and 1 other location - About 45 mins to fix
        htdocs/include/icms_rtl.js on lines 60..60

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

        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

        this.hide = function(id) { var el = new Element(id); document.getElementById(id).className = (el.level == 1 ? "button" : "item"); if (el.level > 1 && this.arrow2) { document.getElementById(id + "-arrow").src = this.arrow1;}
        Severity: Minor
        Found in htdocs/include/icms_rtl.js and 1 other location - About 45 mins to fix
        htdocs/include/icms_rtl.js on lines 64..64

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

        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

        nodes[i].id = id + "-" + (tree.length - 1) + "-section"; var box1 = document.getElementById(id + "-" + (tree.length - 1)); var box2 = document.getElementById(nodes[i].id); var el = new Element(box1.id); if (el.level == 1) { if (this.type == "horizontal") { box2.style.top = (box1.offsetTop + box1.offsetHeight + this.position.level1.top) + "px"; if (this.browser.ie5) { box2.style.left = (this.position.level1.left) + "px";} else {
        Severity: Minor
        Found in htdocs/include/icms_rtl.js and 1 other location - About 35 mins to fix
        htdocs/include/icms_rtl.js on lines 43..43

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

        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 (this.type == "vertical") { box2.style.top = (box1.offsetTop + this.position.level1.top) + "px"; if (this.browser.ie5) { box2.style.left = (box1.offsetWidth + this.position.level1.left) + "px";} else { box2.style.left = (box1.offsetLeft + box1.offsetWidth + this.position.level1.Left) + "px";}
        Severity: Minor
        Found in htdocs/include/icms_rtl.js and 1 other location - About 35 mins to fix
        htdocs/include/icms_rtl.js on lines 39..39

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

        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