src/xmlparser/node2json.js
Function compress
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
Open
function compress(arr, options, jPath){
let text;
const compressedObj = {};
for (let i = 0; i < arr.length; i++) {
const tagObj = arr[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 compress
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function compress(arr, options, jPath){
let text;
const compressedObj = {};
for (let i = 0; i < arr.length; i++) {
const tagObj = arr[i];
Avoid deeply nested control flow statements. Open
Open
if(options.alwaysCreateTextNode) val[options.textNodeName] = "";
else val = "";
Avoid deeply nested control flow statements. Open
Open
if (options.isArray(property, newJpath, isLeaf )) {
compressedObj[property] = [val];
}else{
compressedObj[property] = val;
}
Avoid deeply nested control flow statements. Open
Open
if(!Array.isArray(compressedObj[property])) {
compressedObj[property] = [ compressedObj[property] ];
}
Function assignAttributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function assignAttributes(obj, attrMap, jpath, options){
if (attrMap) {
const keys = Object.keys(attrMap);
const len = keys.length; //don't make it inline
for (let i = 0; i < len; 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
TODO found Open
Open
//TODO: if a node is not an array, then check if it should be an array
- Exclude checks