lizasolomyannik/frontend-project-lvl2

View on GitHub

Showing 6 of 6 total issues

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

const plain = (data) => {
  const iter = (node, prevKey = '') => {
    const name = node.keyName;
    const nodeType = node.type;
    const fullName = prevKey ? `${prevKey}.${name}` : `${name}`;
Severity: Minor
Found in src/formatters/plain.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 getDiffTree has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const getDiffTree = (obj1, obj2) => {
  const keys = _.sortBy([...new Set([...Object.keys(obj1), ...Object.keys(obj2)])]);
  const resultArray = keys.map((key) => {
    if (!_.has(obj1, key)) {
      return { keyName: key, type: 'added', value2: obj2[key] };
Severity: Minor
Found in src/difftree.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 stylish has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const stylish = (data) => {
  const iter = (node, depth) => {
    const name = node.keyName;
    const nodeType = node.type;
    if (nodeType === 'deleted') {
Severity: Minor
Found in src/formatters/stylish.js - About 45 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 { keyName: key, type: 'unchanged', value: obj1[key] };
Severity: Major
Found in src/difftree.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

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

      Avoid too many return statements within this function.
      Open

          return [];
      Severity: Major
      Found in src/formatters/plain.js - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language