XoopsModules25x/smallworld

View on GitHub
assets/js/jquery.history.js

Summary

Maintainability
D
1 day
Test Coverage

Function historyCheck has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    historyCheck: function () {
        // if ((xoops_smallworld.browser.msie) && (xoops_smallworld.browser.version < 8)) {
        if (xoops_smallworld.browser.msie) {
            // On IE, check for location.hash of iframe
            var ihistory = xoops_smallworld("#xoops_smallworld_history")[0];
Severity: Minor
Found in assets/js/jquery.history.js - About 6 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 historyCheck has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    historyCheck: function () {
        // if ((xoops_smallworld.browser.msie) && (xoops_smallworld.browser.version < 8)) {
        if (xoops_smallworld.browser.msie) {
            // On IE, check for location.hash of iframe
            var ihistory = xoops_smallworld("#xoops_smallworld_history")[0];
Severity: Minor
Found in assets/js/jquery.history.js - About 1 hr to fix

    Function historyLoad has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        historyLoad: function (hash) {
            var newhash;
            hash = decodeURIComponent(hash.replace(/\?.*$/, ''));
    
            if (xoops_smallworld.browser.safari) {
    Severity: Minor
    Found in assets/js/jquery.history.js - About 1 hr to fix

      Function historyInit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          historyInit: function (callback, src) {
              xoops_smallworld.historyCallback = callback;
              if (src) xoops_smallworld.historyIframeSrc = src;
              var current_hash = location.hash.replace(/\?.*$/, '');
      
      
      Severity: Minor
      Found in assets/js/jquery.history.js - About 1 hr to fix

        Function historyInit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            historyInit: function (callback, src) {
                xoops_smallworld.historyCallback = callback;
                if (src) xoops_smallworld.historyIframeSrc = src;
                var current_hash = location.hash.replace(/\?.*$/, '');
        
        
        Severity: Minor
        Found in assets/js/jquery.history.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

        Avoid deeply nested control flow statements.
        Open

                            if (cachedHash != undefined) {
                                xoops_smallworld.historyCurrentHash = location.hash.replace(/\?.*$/, '');
                                xoops_smallworld.historyCallback(cachedHash);
                            }
        Severity: Major
        Found in assets/js/jquery.history.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (historyDelta < 0) { // back button has been pushed
                                  // move items to forward stack
                                  for (var i = 0; i < Math.abs(historyDelta); i++) xoops_smallworld.historyForwardStack.unshift(xoops_smallworld.historyBackStack.pop());
                              } else { // forward button has been pushed
                                  // move items to back stack
          Severity: Major
          Found in assets/js/jquery.history.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            } else if (xoops_smallworld.historyBackStack[xoops_smallworld.historyBackStack.length - 1] == undefined && !xoops_smallworld.isFirst) {
                                // back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
                                // document.URL doesn't change in Safari
                                if (location.hash) {
                                    var current_hash = location.hash;
            Severity: Major
            Found in assets/js/jquery.history.js - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status