Zhar-anna/frontend-project-lvl2

View on GitHub

Showing 6 of 6 total issues

Function findDiff has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const findDiff = (obj1, obj2) => {
  const sortedKeys = _.sortBy(Object.keys({ ...obj1, ...obj2 }));
  const result = sortedKeys.map((key) => {
    if (_.isObject(obj1[key]) && _.isObject(obj2[key])) {
      return {
Severity: Minor
Found in src/findDiff.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 findDiff has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const findDiff = (obj1, obj2) => {
  const sortedKeys = _.sortBy(Object.keys({ ...obj1, ...obj2 }));
  const result = sortedKeys.map((key) => {
    if (_.isObject(obj1[key]) && _.isObject(obj2[key])) {
      return {
Severity: Minor
Found in src/findDiff.js - About 1 hr to fix

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

      const result = sortedKeys.map((key) => {
        if (_.isObject(obj1[key]) && _.isObject(obj2[key])) {
          return {
            name: key,
            children: findDiff(obj1[key], obj2[key]),
    Severity: Minor
    Found in src/findDiff.js - About 1 hr to fix

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

      const plain = (diff, fileName = []) => {
        const {
          type, children, name, value, value1, value2,
        } = diff;
        const nestedKeys = [...fileName, name];
      Severity: Minor
      Found in src/formatters/plain.js - About 1 hr to fix

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

        const stylish = (diff, depth = 0) => {
          const {
            name, value, type, value1, value2, children,
          } = diff;
        
        
        Severity: Minor
        Found in src/formatters/stylish.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

              return {
                name: key,
                value: obj1[key],
                type: 'unchanged',
              };
          Severity: Major
          Found in src/findDiff.js - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language