File util.js
has 998 lines of code (exceeds 250 allowed). Consider refactoring. Open
// utility functions
// first check if moment.js is already loaded in the browser window, if so,
// use this instance. Else, load via commonjs.
Function convert
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
exports.convert = function (object, type) {
var match;
if (object === undefined) {
return undefined;
- 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 convert
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.convert = function (object, type) {
var match;
if (object === undefined) {
return undefined;
Function mergeOptions
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
exports.mergeOptions = function (mergeTarget, options, option, globalOptions = {}) {
// Local helpers
var isPresent = function(obj) {
return obj !== null && obj !== undefined;
}
- 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 deepExtend
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
exports.deepExtend = function (a, b, protoExtend=false, allowDeletion=false) {
for (var prop in b) {
if (b.hasOwnProperty(prop) || protoExtend === true) {
if (b[prop] && b[prop].constructor === Object) {
if (a[prop] === undefined) {
- 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 parseColor
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
exports.parseColor = function (color) {
var c;
if (exports.isString(color) === true) {
if (exports.isValidRGB(color) === true) {
var rgb = color.substr(4).substr(0, color.length - 5).split(',').map(function (value) { return parseInt(value) });
- 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 selectiveNotDeepExtend
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
exports.selectiveNotDeepExtend = function (propsToExclude, a, b, allowDeletion = false) {
// TODO: add support for Arrays to deepExtend
// NOTE: array properties have an else-below; apparently, there is a problem here.
if (Array.isArray(b)) {
throw new TypeError('Arrays are not supported by deepExtend');
- 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 parseColor
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.parseColor = function (color) {
var c;
if (exports.isString(color) === true) {
if (exports.isValidRGB(color) === true) {
var rgb = color.substr(4).substr(0, color.length - 5).split(',').map(function (value) { return parseInt(value) });
Function mergeOptions
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.mergeOptions = function (mergeTarget, options, option, globalOptions = {}) {
// Local helpers
var isPresent = function(obj) {
return obj !== null && obj !== undefined;
}
Function selectiveDeepExtend
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.selectiveDeepExtend = function (props, a, b, allowDeletion = false) {
// TODO: add support for Arrays to deepExtend
if (Array.isArray(b)) {
throw new TypeError('Arrays are not supported by deepExtend');
}
- 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 binarySearchValue
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.binarySearchValue = function (orderedItems, target, field, sidePreference, comparator) {
var maxIterations = 10000;
var iteration = 0;
var low = 0;
var high = orderedItems.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 getType
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.getType = function (object) {
var type = typeof object;
if (type == 'object') {
if (object === null) {
- 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 bridgeObject
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.bridgeObject = function (referenceObject) {
if (referenceObject !== null && typeof referenceObject === "object") { // !!! typeof null === 'object'
var objectTo = Object.create(referenceObject);
if (referenceObject instanceof Element) {
// Avoid bridging DOM objects
- 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 topMost
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
exports.topMost = function (pile, accessors) {
let candidate;
if (!Array.isArray(accessors)) {
accessors = [accessors];
}
- 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 fillIfDefined
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
exports.fillIfDefined = function (a, b, allowDeletion = false) {
// NOTE: iteration of properties of a
// NOTE: prototype properties iterated over as well
for (var prop in a) {
if (b[prop] !== undefined) {
- 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 selectiveBridgeObject
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
exports.selectiveBridgeObject = function (fields, referenceObject) {
if (referenceObject !== null && typeof referenceObject === "object") { // !!! typeof null === 'object'
var objectTo = Object.create(referenceObject);
for (var i = 0; i < fields.length; i++) {
if (referenceObject.hasOwnProperty(fields[i])) {
- 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 getType
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.getType = function (object) {
var type = typeof object;
if (type == 'object') {
if (object === null) {
Function binarySearchValue
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.binarySearchValue = function (orderedItems, target, field, sidePreference, comparator) {
var maxIterations = 10000;
var iteration = 0;
var low = 0;
var high = orderedItems.length - 1;
Function selectiveNotDeepExtend
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.selectiveNotDeepExtend = function (propsToExclude, a, b, allowDeletion = false) {
// TODO: add support for Arrays to deepExtend
// NOTE: array properties have an else-below; apparently, there is a problem here.
if (Array.isArray(b)) {
throw new TypeError('Arrays are not supported by deepExtend');
Function forEach
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
exports.forEach = function (object, callback) {
var i,
len;
if (Array.isArray(object)) {
// array
- 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 (typeof referenceObject[i] == "object") {
objectTo[i] = exports.bridgeObject(referenceObject[i]);
}
Function selectiveExtend
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
exports.selectiveExtend = function (props, a, b) { // eslint-disable-line no-unused-vars
if (!Array.isArray(props)) {
throw new Error('Array with property names expected as first argument');
}
- 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
for (let i = 0; i < b[prop].length; i++) {
a[prop].push(b[prop][i]);
}
Function binarySearchValue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
exports.binarySearchValue = function (orderedItems, target, field, sidePreference, comparator) {
Function binarySearchCustom
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.binarySearchCustom = function (orderedItems, comparator, field, field2) {
var maxIterations = 10000;
var iteration = 0;
var low = 0;
var high = orderedItems.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 RGBToHSV
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.RGBToHSV = function (red, green, blue) {
red = red / 255; green = green / 255; blue = blue / 255;
var minRGB = Math.min(red, Math.min(green, blue));
var maxRGB = Math.max(red, Math.max(green, blue));
- 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 'Array';
Avoid too many return
statements within this function. Open
return '/Date(' + object + ')/';
Avoid too many return
statements within this function. Open
return moment(object);
Avoid too many return
statements within this function. Open
return moment(object.valueOf());
Avoid too many return
statements within this function. Open
return moment(object); // parse string
Avoid too many return
statements within this function. Open
return 'Number';
Avoid too many return
statements within this function. Open
return type;
Avoid too many return
statements within this function. Open
return new Date(object);
Avoid too many return
statements within this function. Open
return object.toISOString();
Avoid too many return
statements within this function. Open
return '/Date(' + value + ')/';
Avoid too many return
statements within this function. Open
return moment(new Date(object)).toDate(); // parse string
Avoid too many return
statements within this function. Open
return moment(Number(match[1])); // parse number
Avoid too many return
statements within this function. Open
return 'Object';
Avoid too many return
statements within this function. Open
return new Date(object.valueOf());
Avoid too many return
statements within this function. Open
return moment(object).format(); // ISO 8601
Avoid too many return
statements within this function. Open
return '/Date(' + object.valueOf() + ')/';
Avoid too many return
statements within this function. Open
return moment(object);
Avoid too many return
statements within this function. Open
return new Date(object);
Avoid too many return
statements within this function. Open
return Number(object.valueOf());
Avoid too many return
statements within this function. Open
return 'Date';
Avoid too many return
statements within this function. Open
return 'Boolean';
Avoid too many return
statements within this function. Open
return 'undefined';
Avoid too many return
statements within this function. Open
return new Date(Number(match[1])); // parse number
Avoid too many return
statements within this function. Open
return 'String';
Avoid too many return
statements within this function. Open
return new Date(object.valueOf());
Avoid too many return
statements within this function. Open
return object.toDate().toISOString();
Avoid too many return
statements within this function. Open
return new Date(Number(match[1])).toISOString(); // parse number
Function overrideOpacity
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.overrideOpacity = function (color, opacity) {
var rgb;
if (color.indexOf("rgba") != -1) {
return color;
}
- 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 removeEventListener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.removeEventListener = function (element, action, listener, useCapture) {
if (element.removeEventListener) {
// non-IE browsers
if (useCapture === undefined)
useCapture = 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 assignAllKeys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.assignAllKeys = function (obj, value) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (typeof obj[prop] !== 'object') {
obj[prop] = value;
- 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 extend
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.extend = function (a, b) { // eslint-disable-line no-unused-vars
for (var i = 1; i < arguments.length; i++) {
var other = arguments[i];
for (var prop in other) {
if (other.hasOwnProperty(prop)) {
- 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 addEventListener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.addEventListener = function (element, action, listener, useCapture) {
if (element.addEventListener) {
if (useCapture === undefined)
useCapture = 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
TODO found Open
// TODO: add support for Arrays to deepExtend
- Exclude checks
TODO found Open
// TODO: add support for Arrays to deepExtend
- Exclude checks