FedirAnichkin/project-lvl2-s491

View on GitHub

Showing 10 of 10 total issues

Function plain has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

const plain = (ast, path = []) => {
  const plained = ast.map((item) => {
    const {
      key,
      newValue,
Severity: Minor
Found in src/formatters/plain.js - About 2 hrs 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 getAst has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const getAst = (tree1, tree2) => {
  const keys = union(Object.keys(tree1), Object.keys(tree2));
  const result = keys.reduce((acc, key) => {
    if (tree1[key] && tree2[key]) {
      if (isPlainObject(tree1[key]) && isPlainObject(tree2[key])) {
Severity: Minor
Found in src/getAST.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 getAst has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getAst = (tree1, tree2) => {
  const keys = union(Object.keys(tree1), Object.keys(tree2));
  const result = keys.reduce((acc, key) => {
    if (tree1[key] && tree2[key]) {
      if (isPlainObject(tree1[key]) && isPlainObject(tree2[key])) {
Severity: Minor
Found in src/getAST.js - About 1 hr to fix

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

      const result = keys.reduce((acc, key) => {
        if (tree1[key] && tree2[key]) {
          if (isPlainObject(tree1[key]) && isPlainObject(tree2[key])) {
            return [...acc, {
              type: 'complex',
    Severity: Minor
    Found in src/getAST.js - About 1 hr to fix

      Function plain has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const plain = (ast, path = []) => {
        const plained = ast.map((item) => {
          const {
            key,
            newValue,
      Severity: Minor
      Found in src/formatters/plain.js - About 1 hr to fix

        Function tree has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const tree = (ast, l = 0) => {
          const diff = ast.reduce((acc, item) => {
            const {
              key,
              type,
        Severity: Minor
        Found in src/formatters/tree.js - About 1 hr to fix

          Function tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          const tree = (ast, l = 0) => {
            const diff = ast.reduce((acc, item) => {
              const {
                key,
                type,
          Severity: Minor
          Found in src/formatters/tree.js - About 55 mins 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

          Avoid too many return statements within this function.
          Open

              return [...acc, {
                type: 'deleted',
                key,
                oldValue: tree1[key],
              }];
          Severity: Major
          Found in src/getAST.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return [...acc, `  + ${key}: ${stringify(newValue, l + 1)}`];
            Severity: Major
            Found in src/formatters/tree.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return plain(children, newPath);
              Severity: Major
              Found in src/formatters/plain.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language