ostart/project-lvl2-s237

View on GitHub

Showing 7 of 16 total issues

Function getAst has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const getAst = (objBefore, objAfter) => {
  const keysBefore = Object.keys(objBefore);
  const keysAfter = Object.keys(objAfter);
  const united = _.union(keysAfter, keysBefore);

Severity: Minor
Found in src/index.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 renderStringFromAst has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const renderStringFromAst = (arr, tabsCount = 0) => {
  const outArr = arr.map((node) => {
    switch (node.type) {
      case 'updated': {
        const { key, valBefore, valAfter } = node;
Severity: Minor
Found in src/renderers/string.js - About 1 hr to fix

    Function outArr has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const outArr = arr.map((node) => {
        switch (node.type) {
          case 'updated': {
            const { key, valBefore, valAfter } = node;
            const valFrom = getStringFromObj(valBefore, tabsCount + 1);
    Severity: Minor
    Found in src/renderers/string.js - About 1 hr to fix

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

      const renderPlainFromAst = (arr, keyPathArr = []) => {
        const outStr = arr.reduce((acc, obj) => {
          const {
            key, valBefore, valAfter, children,
          } = obj;
      Severity: Minor
      Found in src/renderers/plain.js - About 1 hr to fix

        Avoid too many return statements within this function.
        Open

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

          Avoid too many return statements within this function.
          Open

                  return strIndent.fixed.repeat(tabsCount).concat(strIndent[node.type], key, ': ', valFrom);
          Severity: Major
          Found in src/renderers/string.js - About 30 mins to fix

            Function renderPlainFromAst has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const renderPlainFromAst = (arr, keyPathArr = []) => {
              const outStr = arr.reduce((acc, obj) => {
                const {
                  key, valBefore, valAfter, children,
                } = obj;
            Severity: Minor
            Found in src/renderers/plain.js - About 25 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

            Severity
            Category
            Status
            Source
            Language