Showing 13 of 17 total issues
File ProxyCache.js
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
var verboseLog = (process.env.npm_config_verbose_log)? console.log : function() {},
format = require('util').format,
Promise = require('bluebird'),
httpProxy = require('http-proxy'),
MobileDetect = require('mobile-detect'),
Function handleRequest
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
ProxyCache.prototype.handleRequest = function(req, res){
var proxyCache = this;
if (proxyCache.options.spoofHostHeader){
req.headers.host = proxyCache.proxyTarget;
- 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 ProxyCache
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
var ProxyCache = function(options){
var proxyCache = this;
proxyCache.options = options || {};
proxyCache.options.memGiBThreshold = proxyCache.options.memGiBThreshold || 2;
Function handleRequest
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
ProxyCache.prototype.handleRequest = function(req, res){
var proxyCache = this;
if (proxyCache.options.spoofHostHeader){
req.headers.host = proxyCache.proxyTarget;
Function CacheObject
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var CacheObject = function(cacheKey, input, req){
var co = this,
res = (input instanceof stream.Readable)? input : null,
jsonString = (typeof input === 'string')? input : null,
deserialized = (jsonString)? JSON.parse(jsonString) : {},
Function respondWithCacheObject
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
ProxyCache.prototype.respondWithCacheObject = function(req, res, co){
var proxyCache = this;
for(var headerKey in co.headers){
res.setHeader(headerKey, co.headers[headerKey]);
Function setProxyResponseStream
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
CacheObject.prototype.setProxyResponseStream = function(proxyRes) {
var co = this,
_upstreamEndDefer = Promise.defer(); // TODO: consolidate with `.ready` promise
// Reset buffer array
Function checkIfStale
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
ProxyCacheMongoAdapter.prototype.checkIfStale = function(){
var adapter = this;
if(!adapter.lastPubDate){
verboseLog("Publish date not set.");
Function ProxyCacheMongoAdapter
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ProxyCacheMongoAdapter(proxyCache, options){
var adapter = this;
options = options || {};
adapter.proxyCache = proxyCache;
Function clearAll
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
ProxyCache.prototype.clearAll = function(keyRegex){
var proxyCache = this,
shouldClearTest = (keyRegex && keyRegex instanceof RegExp)?
function regexTest(key){
return keyRegex.test(key);
Function clearAll
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ProxyCache.prototype.clearAll = function(keyRegex){
var proxyCache = this,
shouldClearTest = (keyRegex && keyRegex instanceof RegExp)?
function regexTest(key){
return keyRegex.test(key);
- 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 CacheObject
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
var CacheObject = function(cacheKey, input, req){
var co = this,
res = (input instanceof stream.Readable)? input : null,
jsonString = (typeof input === 'string')? input : null,
deserialized = (jsonString)? JSON.parse(jsonString) : {},
- 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 ProxyCache
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var ProxyCache = function(options){
var proxyCache = this;
proxyCache.options = options || {};
proxyCache.options.memGiBThreshold = proxyCache.options.memGiBThreshold || 2;
- 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"