daniellmb/MemSnap

View on GitHub

Showing 3 of 5 total issues

Function memSnap has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function memSnap (global, url, intervals, notify) {
  var perf = global.performance;

  // check already called and browser support
  if (perf && perf.memory) {
Severity: Minor
Found in memSnap.js - About 1 hr to fix

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

    }(this, function factory() {
      // public API
      return function memSnap(e,m,o,r){var t=e.performance;if(t&&t.memory){var n,a,c=/\{lbl\}/,i=/\{lmt\}/,p=/\{tot\}/,l=/\{use\}/;o=o||{"0s":0,"5m":3e5,"10m":6e5,"15m":9e5,"30m":18e5,"1h":36e5,"3h":108e5,"6h":216e5,"12h":432e5,"24h":864e5,"48h":1728e5},n=function(o,n){e.setTimeout(function(){r&&r(o,t.memory),e.document.createElement("img").src=m.replace(c,e.encodeURIComponent(o)).replace(i,t.memory.jsHeapSizeLimit).replace(p,t.memory.totalJSHeapSize).replace(l,t.memory.usedJSHeapSize)},n)};for(a in o)o.hasOwnProperty(a)&&n(a,o[a])}};
    }));
    Severity: Minor
    Found in memSnap.min.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

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

    function memSnap (global, url, intervals, notify) {
      var perf = global.performance;
    
      // check already called and browser support
      if (perf && perf.memory) {
    Severity: Minor
    Found in memSnap.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

    Severity
    Category
    Status
    Source
    Language