Showing 9 of 12 total issues
Function astToString
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
export const astToString = (ast) => {
const iter = (tree, level) => {
const space = _.repeat(' ', 4 * level);
const stringify = (element) => {
if (element instanceof Object) {
- 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 getObjectsDifferences
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getObjectsDifferences = (object1, object2) => {
const firstObjectKeys = Object.keys(object1);
const secondObjectKeys = Object.keys(object2);
const mixedKeys = _.union(firstObjectKeys, secondObjectKeys);
Function diffArray
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const diffArray = mixedKeys.reduce((acc, key) => {
if ((key in object1) && (key in object2)
&& (object1[key] instanceof Object || object2[key] instanceof Object)) {
const result = {
state: '',
Function getObjectsDifferences
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
export const getObjectsDifferences = (object1, object2) => {
const firstObjectKeys = Object.keys(object1);
const secondObjectKeys = Object.keys(object2);
const mixedKeys = _.union(firstObjectKeys, secondObjectKeys);
- 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 astToString
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const astToString = (ast) => {
const iter = (tree, level) => {
const space = _.repeat(' ', 4 * level);
const stringify = (element) => {
if (element instanceof Object) {
Function iter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const iter = (tree, level) => {
const space = _.repeat(' ', 4 * level);
const stringify = (element) => {
if (element instanceof Object) {
return `{\n${space} ${JSON.stringify(element).replace(/["]/g, '').replace(/[:]/g, ': ').slice(1, -1)}\n${space} }`;
Avoid too many return
statements within this function. Open
Open
return acc;
Avoid too many return
statements within this function. Open
Open
return [...acc, result];
Avoid too many return
statements within this function. Open
Open
return `${acc}\n${space} ${obj.key}: {${iter(obj.children, level + 1)}\n }`;