Showing 17 of 19 total issues
Function map
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
async function map(document, mappings, plugins) {
/**
* @function processMappings
*
- 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 map
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function map(document, mappings, plugins) {
/**
* @function processMappings
*
Function processMappings
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processMappings(mappings, document, result, parentKey) {
_.each(mappings, function(path, key) {
key = parentKey ? `${parentKey}.${key}` : key;
Function cleanURI
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function cleanURI(source, service) {
if (!!source && typeof(source) === "string") {
// Replace all spaces with nothing, and truncate to 400 chars,
- 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 getValue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getValue(path, subDocument) {
if (!path) return;
if (path === '!') return document;
Function parseMappings
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function parseMappings(result, innerResult, path, key, $value, $key) {
Function getLinkType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getLinkType(source, service) {
if (!source || typeof(source) !== "string") return null;
if(!!service && MESSAGING_SERVICES.find(item => item.toLowerCase().trim() === service.toLowerCase().trim())){
- 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 (!!path.prerequisite) {
if (!!eval(path.prerequisite)) _.set(result, fullPath, innerResult);
} else _.set(result, fullPath, innerResult);
Avoid deeply nested control flow statements. Open
if (!!path.prerequisite) {
if (!!eval(path.prerequisite)) _.updateWith(result, key, function(theArray){ theArray.push(innerResult); return theArray }, []);
} else _.updateWith(result, key, function(theArray){ theArray.push(innerResult); return theArray }, []);
Function extractName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function extractName(fullName, position) {
const ALLOWED_POSITIONS = ["firstName", "middleName", "lastName"];
if (!!fullName && typeof(fullName) === "string"
- 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 _.isPlainObject(subDocument) ? _.get(subDocument, path) : _.get(document, path);
Avoid too many return
statements within this function. Open
return plugins[functionCall].apply(null, paramteresValues);
Avoid too many return
statements within this function. Open
} else return getValue(path, $value);
Avoid too many return
statements within this function. Open
} else return null;
Avoid too many return
statements within this function. Open
return isValidValue ? applyTransformation(null, parameters.targetValue, null, subDocument) : null;
Avoid too many return
statements within this function. Open
return getValue(pathWithDefault[0], subDocument) || getValue(`${pathWithDefault[1]}`);
Function getLinkService
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function getLinkService(source, service) {
if (!source || typeof(source) !== "string" || !Joi.validate(source, Joi.string().email({errorLevel: true})).error ) return null;
if (!!service) return service.replace(/\s\s+/g, "").trim().toLowerCase();
- 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"