Showing 27 of 33 total issues
Function sortFunction
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
var sortFunction = function(value) {
return function (a, b) {
if (value.by) {
a = a[value.by];
b = b[value.by];
- 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 request
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
exports.request = function(options, callback) {
var startTime = new Date().getTime(),
headers = options.headers || {},
method = options.method || 'GET',
params = options.params || {},
- 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 parseRequestString
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
var parseRequestString = function(apiCall) {
if (typeof apiCall.request === 'string') {
var parts = apiCall.request.split(' '),
firstPart = parts[0],
lastPart = parts[parts.length-1];
- 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 nestedValue
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
var nestedValue = (function() {
var assertValidArgs = function(hash, nestedKey) {
if (hash == null || typeof hash !== 'object') {
throw new UtilError('nested_value_invalid_hash', 'Expected object as hash argument but got ' + hash + " nestedKey=" + nestedKey);
}
Function equalValues
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
var equalValues = function(value1, value2) {
if (value1 == null && value2 == null) {
// both values are null/undefined
return true;
} else if (_.isRegExp(value2) && !_.isRegExp(value1)) {
- 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 request
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.request = function(options, callback) {
var startTime = new Date().getTime(),
headers = options.headers || {},
method = options.method || 'GET',
params = options.params || {},
Function request
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.request = function(options, callback) {
var startTime = new Date().getTime(),
options = options || {},
method = clientMethod(options),
url = options.url,
Function end
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
end: function(success, results) {
var logPath = this.config.log_path;
if (logPath) {
output("\nlogging all results to " + logPath + "\n");
if (!fs.existsSync(path.dirname(logPath))) fs.mkdirSync(path.dirname(logPath));
- 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 request
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.request = function(options, callback) {
var startTime = new Date().getTime(),
options = options || {},
method = clientMethod(options),
url = options.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 handleProperty
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handleProperty = function(context, property, value) {
switch(property) {
case 'data':
assertValidSchema(value, schema.data);
context.data = util.deepMerge(context.data, value);
Function exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function(context) {
var callbacks = util.array(util.loadModule(context, 'callbacks'));
return {
run: function(key, args, callback) {
async.eachSeries(callbacks, function(callback, next) {
- 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 sort
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports.sort = function(value, response) {
if (!util.isArray(response)) throw new util.Error('select_sort_non_array', 'Sort select function expected array but got ' + JSON.stringify(response));
if (typeof value === 'string') {
value = {order: value};
} else {
- 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
Consider simplifying this complex logical expression. Open
if (value1 && value2 && (_.isObject(value1) && !_.isArray(value1)) && (_.isObject(value2) && !_.isArray(value2))) {
result[key] = deepMerge(value1, value2);
} else {
result[key] = (value2 === undefined ? value1 : value2);
if (result[key] && _.isObject(result[key])) result[key] = _.cloneDeep(result[key]);
Function run
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
exports.run = function(context, suite, test, apiCallRaw, callback) {
Function end
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
end: function(suite, test, apiCall, err, result) {
Function end
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
end: function(suite, test, apiCall, err, result) {
var method = apiCall.request['method'] || "GET";
if (apiCall.it || apiCall.description) output(" "); // indentation
output(method + " " + apiCall.request.url);
var status = err ? "FAILURE!" : "OK!";
- 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 nestedValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var nestedValue = (function() {
var assertValidArgs = function(hash, nestedKey) {
if (hash == null || typeof hash !== 'object') {
throw new UtilError('nested_value_invalid_hash', 'Expected object as hash argument but got ' + hash + " nestedKey=" + nestedKey);
}
- 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 expandPaths
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var expandPaths = function(paths, extensions, topLevel) {
return util.compact(util.flatten(util.map(util.array(paths), function(path) {
if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) {
var subPaths = util.compact(util.map(fs.readdirSync(path), function(subPath) {
return join(path, subPath);
- 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 start
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
start: function(suite, test, apiCall) {
if (apiCall.pending) {
stats.pending_api_calls++;
} else {
stats.api_calls++;
- 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 too many return
statements within this function. Open
return value1.toString() === value2.toString();