mambax7/smartfaq

View on GitHub
assets/js/overlib/mini/overlib_followscroll_mini.js

Summary

Maintainability
F
1 wk
Test Coverage

Function scroll_placeLayer has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
Open

function scroll_placeLayer() {
    var placeX, placeY, widthFix = 0;
    var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor);
    if (eval('o3_frame.' + docRoot) && eval("typeof o3_frame." + docRoot + ".clientWidth=='number'") && eval('o3_frame.' + docRoot + '.clientWidth')) {
        iwidth = eval('o3_frame.' + docRoot + '.clientWidth');
Severity: Minor
Found in assets/js/overlib/mini/overlib_followscroll_mini.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 scroll_placeLayer has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function scroll_placeLayer() {
    var placeX, placeY, widthFix = 0;
    var hasAnchor = (typeof o3_anchor != 'undefined' && o3_anchor);
    if (eval('o3_frame.' + docRoot) && eval("typeof o3_frame." + docRoot + ".clientWidth=='number'") && eval('o3_frame.' + docRoot + '.clientWidth')) {
        iwidth = eval('o3_frame.' + docRoot + '.clientWidth');
Severity: Major
Found in assets/js/overlib/mini/overlib_followscroll_mini.js - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                        if (placeX < 0) placeX = 0;
    Severity: Major
    Found in assets/js/overlib/mini/overlib_followscroll_mini.js - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (o3_followscroll && o3_sticky && (o3_relx || o3_rely) && (typeof o3_draggable == 'undefined' || !o3_draggable)) {
              if (typeof over.scroller == 'undefined' || over.scroller.canScroll) over.scroller = new Scroller(placeX - winoffset, placeY - scrolloffset, o3_followscrollrefresh);
          }
      Severity: Major
      Found in assets/js/overlib/mini/overlib_followscroll_mini.js - About 40 mins to fix

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

            if (hasAnchor) {
                placeX = rmrkPosition[0];
                placeY = rmrkPosition[1];
            } else {
                winoffset = (olIe4) ? eval('o3_frame.' + docRoot + '.scrollLeft') : o3_frame.pageXOffset;
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 5 days to fix
        assets/js/overlib/mini/overlib_anchor_mini.js on lines 77..152

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

        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 repositionOver() {
            var X, Y, pgLeft, pgTop;
            pgTop = getPageScrollY();
            pgLeft = getPageScrollX();
            X = getLayerLeft(over) - pgLeft;
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 6 hrs to fix
        assets/js/overlib/overlib_followscroll.js on lines 246..255

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

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

            if (eval('o3_frame.' + docRoot) && eval("typeof o3_frame." + docRoot + ".clientWidth=='number'") && eval('o3_frame.' + docRoot + '.clientWidth')) {
                iwidth = eval('o3_frame.' + docRoot + '.clientWidth');
            } else if (typeof(o3_frame.innerWidth) == 'number') {
                widthFix = Math.ceil(1.2 * (o3_frame.outerWidth - o3_frame.innerWidth));
                iwidth = o3_frame.innerWidth;
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 2 other locations - About 4 hrs to fix
        assets/js/overlib/mini/overlib_anchor_mini.js on lines 71..76
        assets/js/overlib/mini/overlib_mini.js on lines 425..430

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

        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

        function parseScrollExtras(pf, i, ar) {
            var k = i, v;
            if (k < ar.length) {
                if (ar[k] == FOLLOWSCROLL) {
                    eval(pf + 'followscroll=(' + pf + 'followscroll==0)?1:0');
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 3 hrs to fix
        assets/js/overlib/overlib_followscroll.js on lines 53..66

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

        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 (o3_followscroll && o3_sticky && (o3_relx || o3_rely) && (typeof o3_draggable == 'undefined' || !o3_draggable)) {
                if (typeof over.scroller == 'undefined' || over.scroller.canScroll) over.scroller = new Scroller(placeX - winoffset, placeY - scrolloffset, o3_followscrollrefresh);
            }
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 2 hrs to fix
        assets/js/overlib/overlib_followscroll.js on lines 191..193

        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

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

        function cancelScroll() {
            if (!o3_followscroll || typeof over.scroller == 'undefined') return;
            over.scroller.canScroll = 1;
            if (over.scroller.timer) {
                clearTimeout(over.scroller.timer);
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 2 hrs to fix
        assets/js/overlib/overlib_followscroll.js on lines 211..219

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

        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 Scroller(X, Y, refresh) {
            this.canScroll = 0;
            this.refresh = refresh;
            this.x = X;
            this.y = Y;
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 1 hr to fix
        assets/js/overlib/overlib_followscroll.js on lines 202..208

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

        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

        function getLayerTop(layer) {
            if (layer.pageY) return layer.pageY;
            if (layer.style.top) return parseInt(layer.style.top);
            return -1;
        }
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 1 hr to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 154..158

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

        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

        function getLayerLeft(layer) {
            if (layer.pageX) return layer.pageX;
            if (layer.style.left) return parseInt(layer.style.left);
            return -1;
        }
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 1 hr to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 149..153

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

        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

        function getPageScrollY() {
            if (o3_frame.pageYOffset) return o3_frame.pageYOffset;
            if (eval(docRoot)) return eval('o3_frame.' + docRoot + '.scrollTop');
            return -1;
        }
        Severity: Minor
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 50 mins to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 144..148

        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

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

        function getPageScrollX() {
            if (o3_frame.pageXOffset) return o3_frame.pageXOffset;
            if (eval(docRoot)) return eval('o3_frame.' + docRoot + '.scrollLeft');
            return -1;
        }
        Severity: Minor
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 50 mins to fix
        assets/js/overlib/mini/overlib_followscroll_mini.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 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