Showing 16 of 22 total issues
Function beforeSend
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
beforeSend: function(req, res, page, next) {
if (page.html) {
var headerMatch = /<meta property=['"]prerender:([^'"]+)['"] content=['"]([^'"]+)['"]>/g;
var head = page.html.split('</head>', 1).pop();
var match;
- Read upRead up
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 init
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
PhantomEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
var _this = this;
this.initializationCallback = initCallback;
this.hasInitializationCallback = true;
Function init
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
WebDriverEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
var _this = this;
this.initializationCallback = initCallback;
this.hasInitializationCallback = true;
Function phantom
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.phantom = phantom.create("--load-images=false", "--ignore-ssl-errors=true", "--ssl-protocol=any", this.engineSettings, function(ph) {
_this.phantom.ph = ph;
_this.phantom.ph.createPage(function(phantomPage) {
_this.phantom.page = phantomPage;
Function init
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
JSDomEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
var _this = this;
this.initializationCallback = initCallback;
this.hasInitializationCallback = true;
Function afterRender
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
PrerenderRenderer.prototype.afterRender = function(page) {
var _this = this;
clearTimeout(this.renderTimer);
this.renderTimer = null;
Function beforeSend
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
beforeSend: function(req, res, page, next) {
if (page.html) {
var headerMatch = /<meta property=['"]prerender:([^'"]+)['"] content=['"]([^'"]+)['"]>/g;
var head = page.html.split('</head>', 1).pop();
var match;
Function log
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
PrerenderLogger.prototype.log = function(level) {
var _this = this;
if (this.levels[this.config.level] > this.levels[level]) {
return;
Function exports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(environment) {
var ENV = {
modulePrefix: 'example',
environment: environment,
baseURL: '/',
Function onPageReady
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
JSDomEngine.prototype.onPageReady = function() {
var _this = this;
if (this.hasInitializationCallback) {
this.hasInitializationCallback = false;
- Read upRead up
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 (headerName === 'Location') {
headerValue = decodeURIComponent(headerValue);
}
Function onRequest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
PrerenderServer.prototype.onRequest = function(req, res) {
var addr = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var agent = req.headers['user-agent'] || "Unknown";
var user = addr + ' (' + agent + ')';
var reqUrl = this.parseURL(req.url);
- Read upRead up
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 pluginEvent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
PrerenderRenderer.prototype.pluginEvent = function(methodName, args, callback) {
var _this = this;
var index = 0;
callback = callback || function() {};
- Read upRead up
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 onPageReady
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
WebDriverEngine.prototype.onPageReady = function() {
var _this = this;
if (this.hasInitializationCallback) {
this.hasInitializationCallback = false;
- Read upRead up
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 beforeSend
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
beforeSend: function(req, res, page, next) {
if (page.statusCode < 400) {
var object = {
url: page.url,
status: page.statusCode,
- Read upRead up
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 onPageReady
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
PhantomEngine.prototype.onPageReady = function() {
var _this = this;
if (this.hasInitializationCallback) {
this.hasInitializationCallback = false;
- Read upRead up
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"