Showing 6 of 6 total issues
Function calcDiff
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export const calcDiff = (o1, o2) => {
const keys1 = Object.keys(o1);
const keys2 = Object.keys(o2);
const sortedUnionKeys = _.sortBy(_.union(keys1, keys2), (k) => k);
const result = sortedUnionKeys.reduce((acc, 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 iter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const iter = (tree, currentPath) => {
const keys = Object.keys(tree);
const result = keys.reduce((acc, key, index) => {
const splitedKey = key.split(' ');
const sign = splitedKey[0];
Function plainStringify
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const plainStringify = (value, replacer = ' ', spacesCount = 1) => {
const iter = (el, counter) => {
const arr = Object.entries(el).map(([key, val]) => {
if (typeof val === 'object' && val) return (`${replacer.repeat(counter)}${key}: ${iter(val, counter + spacesCount)}`);
return (`${replacer.repeat(counter)}${key}: ${val}`);
- 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 stringify
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const stringify = (value) => {
if (isPlainObject(value)) return plainStringify(value);
const iter = (currentValue, depth = 1) => {
if (!_.isObject(currentValue)) {
- 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 { ...acc, [`- ${key}`]: value1, [`+ ${key}`]: value2 };
Avoid too many return
statements within this function. Open
return acc;