tmaiaroto/telepathic-black-panther

View on GitHub

Showing 76 of 76 total issues

Function _on has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var _on = function (eventString, eventHandler) {
  // Bind an event string(s) to an event handler function.
  //
  // Parameter
  //   eventString
Severity: Minor
Found in dev/js/telepathic-black-panther.js - About 1 hr to fix

Function inactivityCheck has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        var inactivityCheck = setInterval(function() {
            // Check to see if active is false, if so - there has been no activity.
            if(!active) {
                // Then check if enough time has passed for the periods defined in `opts.periods`
                for(var i in opts.periods) {
Severity: Minor
Found in src/engagement.js - About 1 hr to fix

Function 8 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

},{}],8:[function(require,module,exports){
/*!
 * ki.js - jQuery-like API super-tiny JavaScript library
 * Copyright (c) 2014 Denis Ciccale (@tdecs)
 * Released under MIT license
Severity: Minor
Found in dev/js/telepathic-black-panther.js - About 1 hr to fix

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

var _emit = function (eventString) {
  // Emit an event to execute the bound event handler functions.
  // The event handlers are executed immediately.
  //
  // Parameter
Severity: Minor
Found in dev/js/telepathic-black-panther.js - About 1 hr to fix

Function log has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            log: function(message, obj) {
                if(this.config.debug && console !== undefined) {
                    var style = "";
                    switch(obj) {
                        case "warn":
Severity: Minor
Found in dev/js/telepathic-black-panther.js - About 1 hr to fix

Function isOnScreen has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    isOnScreen: function(x, y) {
        if(x === null || typeof x === 'undefined') { x = 1; }
        if(y === null || typeof y === 'undefined') { y = 1; }
        
        var viewport = {};
Severity: Minor
Found in src/ki.plugins.js - About 1 hr to fix

Function isOnScreen has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    isOnScreen: function(x, y) {
        if(x === null || typeof x === 'undefined') { x = 1; }
        if(y === null || typeof y === 'undefined') { y = 1; }
        
        var viewport = {};
Severity: Minor
Found in dev/js/telepathic-black-panther.js - About 1 hr to fix

Function log has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            log: function(message, obj) {
                if(this.config.debug && console !== undefined) {
                    var style = "";
                    switch(obj) {
                        case "warn":
Severity: Minor
Found in src/main.js - About 1 hr to fix

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

    isOnScreen: function(x, y) {
        if(x === null || typeof x === 'undefined') { x = 1; }
        if(y === null || typeof y === 'undefined') { y = 1; }
        
        var viewport = {};
Severity: Minor
Found in src/ki.plugins.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

Avoid deeply nested control flow statements.
Open

                            if(opts.event === "click") {
                                opts.event = "focus";
                            }
Severity: Major
Found in dev/js/telepathic-black-panther.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if(element.className) {
                            tgtStr += "." + element.className;
                        } else {
                            // No classes? Position on page? -- this could vary greatly and is up to the client device...so no.
                            // var offset = $ki(element).offset();
Severity: Major
Found in src/core.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if(element.className) {
                            tgtStr += "." + element.className;
                        } else {
                            // No classes? Position on page? -- this could vary greatly and is up to the client device...so no.
                            // var offset = $ki(element).offset();
Severity: Major
Found in dev/js/telepathic-black-panther.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          if (subRouteMap.hasOwnProperty(rs)) {
            delete this.routeMap[rs];
          }
Severity: Major
Found in dev/js/telepathic-black-panther.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                            if(opts.event === "click") {
                                opts.event = "focus";
                            }
Severity: Major
Found in src/engagement.js - About 45 mins to fix

Function leave has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    leave: function(opts) {
        opts = this.extend({
            "_method": "leave",
            "category": "behavior",
            "action": "",
Severity: Minor
Found in src/engagement.js - About 35 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 pageWordCount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    pageWordCount: function(discountedSelectors) {
        // discount obvious selectors (so we don't count text in the footer, nav, navbar, etc.)
        discountedSelectors = (typeof(discountedSelectors) !== 'object') ? ['.footer', '.navbar', '.nav', '.header', '.ad', '.advertisement']:discountedSelectors;
        
        var bodyInnerText = $ki('body')[0].innerText || $ki('body')[0].textContent || "";
Severity: Minor
Found in src/analysis.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

Severity
Category
Status
Source
Language