Showing 7 of 16 total issues
Function getAst
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
const getAst = (objBefore, objAfter) => {
const keysBefore = Object.keys(objBefore);
const keysAfter = Object.keys(objAfter);
const united = _.union(keysAfter, keysBefore);
- 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 renderStringFromAst
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderStringFromAst = (arr, tabsCount = 0) => {
const outArr = arr.map((node) => {
switch (node.type) {
case 'updated': {
const { key, valBefore, valAfter } = node;
Function outArr
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const outArr = arr.map((node) => {
switch (node.type) {
case 'updated': {
const { key, valBefore, valAfter } = node;
const valFrom = getStringFromObj(valBefore, tabsCount + 1);
Function renderPlainFromAst
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderPlainFromAst = (arr, keyPathArr = []) => {
const outStr = arr.reduce((acc, obj) => {
const {
key, valBefore, valAfter, children,
} = obj;
Avoid too many return
statements within this function. Open
Open
return [...acc, { type: 'deleted', key, valBefore: objBefore[key] }];
Avoid too many return
statements within this function. Open
Open
return strIndent.fixed.repeat(tabsCount).concat(strIndent[node.type], key, ': ', valFrom);
Function renderPlainFromAst
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
const renderPlainFromAst = (arr, keyPathArr = []) => {
const outStr = arr.reduce((acc, obj) => {
const {
key, valBefore, valAfter, children,
} = obj;
- 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"