Showing 9 of 14 total issues
Function buildAST
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const buildAST = (data1, data2) => {
const data1Keys = _.keys(data1);
const data2Keys = _.keys(data2);
const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));
Function children
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const children = sortedKeys.map((key) => {
if (!_.has(data1, key)) {
return {
type: 'added',
key,
Function makeStylishDiff
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const makeStylishDiff = (tree) => {
const iter = (node, depth) => {
switch (node.type) {
case 'root': {
const result = node.children.flatMap((child) => iter(child, depth));
Function buildAST
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
const buildAST = (data1, data2) => {
const data1Keys = _.keys(data1);
const data2Keys = _.keys(data2);
const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));
- 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
Open
const iter = (node, depth) => {
switch (node.type) {
case 'root': {
const result = node.children.flatMap((child) => iter(child, depth));
return joinStrings(result, depth);
Avoid too many return
statements within this function. Open
Open
return `${currentIndent(depth)} ${node.key}: ${stringify(node.value, depth + 1)}`;
Avoid too many return
statements within this function. Open
Open
return {
type: 'changed',
key,
value: data1[key],
value2: data2[key],
Avoid too many return
statements within this function. Open
Open
return null;
Avoid too many return
statements within this function. Open
Open
return [`${currentIndent(depth)}- ${node.key}: ${stringify(node.value, depth + 1)}`,
`${currentIndent(depth)}+ ${node.key}: ${stringify(node.value2, depth + 1)}`];