Abikimoz/frontend-project-46

View on GitHub

Showing 9 of 14 total issues

Function buildAST has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const buildAST = (data1, data2) => {
  const data1Keys = _.keys(data1);
  const data2Keys = _.keys(data2);
  const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));

Severity: Minor
Found in src/buildAST.js - About 1 hr to fix

    Function children has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const children = sortedKeys.map((key) => {
        if (!_.has(data1, key)) {
          return {
            type: 'added',
            key,
    Severity: Minor
    Found in src/buildAST.js - About 1 hr to fix

      Function makeStylishDiff has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const makeStylishDiff = (tree) => {
        const iter = (node, depth) => {
          switch (node.type) {
            case 'root': {
              const result = node.children.flatMap((child) => iter(child, depth));
      Severity: Minor
      Found in src/formatters/stylish.js - About 1 hr to fix

        Function buildAST has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const buildAST = (data1, data2) => {
          const data1Keys = _.keys(data1);
          const data2Keys = _.keys(data2);
          const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));
        
        
        Severity: Minor
        Found in src/buildAST.js - About 1 hr to fix

        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 = (node, depth) => {
            switch (node.type) {
              case 'root': {
                const result = node.children.flatMap((child) => iter(child, depth));
                return joinStrings(result, depth);
        Severity: Minor
        Found in src/formatters/stylish.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

                  return `${currentIndent(depth)}  ${node.key}: ${stringify(node.value, depth + 1)}`;
          Severity: Major
          Found in src/formatters/stylish.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return {
                  type: 'changed',
                  key,
                  value: data1[key],
                  value2: data2[key],
            Severity: Major
            Found in src/buildAST.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return null;
              Severity: Major
              Found in src/formatters/plain.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return [`${currentIndent(depth)}- ${node.key}: ${stringify(node.value, depth + 1)}`,
                          `${currentIndent(depth)}+ ${node.key}: ${stringify(node.value2, depth + 1)}`];
                Severity: Major
                Found in src/formatters/stylish.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language