mambax7/smartfaq

View on GitHub
assets/js/overlib/overlib_followscroll.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);

    // HORIZONTAL PLACEMENT
Severity: Minor
Found in assets/js/overlib/overlib_followscroll.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);

    // HORIZONTAL PLACEMENT
Severity: Major
Found in assets/js/overlib/overlib_followscroll.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/overlib_followscroll.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/overlib_followscroll.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 {
                // Horizontal scroll offset
        Severity: Major
        Found in assets/js/overlib/overlib_followscroll.js and 1 other location - About 5 days to fix
        assets/js/overlib/overlib_anchor.js on lines 128..232

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

        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/overlib_followscroll.js and 1 other location - About 6 hrs to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 159..167

        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 2 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/overlib_followscroll.js and 1 other location - About 4 hrs to fix
        assets/js/overlib/overlib_anchor.js on lines 121..126

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

        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/overlib_followscroll.js and 1 other location - About 3 hrs to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 20..33

        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/overlib_followscroll.js and 1 other location - About 2 hrs to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 120..122

        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) {
        Severity: Major
        Found in assets/js/overlib/overlib_followscroll.js and 1 other location - About 2 hrs to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 131..138

        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/overlib_followscroll.js and 1 other location - About 1 hr to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 124..130

        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

        There are no issues that match your filters.

        Category
        Status