MrFSP/backend-project-lvl2

View on GitHub

Showing 6 of 6 total issues

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

const getRendering = (data, ancestry = '') => data.map((item) => {
  const {
    key, type, children, newValue, oldValue,
  } = item;
  const currentKey = ancestry === '' ? key : `${ancestry}.${key}`;
Severity: Minor
Found in src/formatters/plain.js - About 1 hr to fix

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

    const getRendering = (data, lvl = 0) => data.map((item) => {
      const currentLvl = lvl + 2;
      const {
        type, key, newValue, oldValue, children,
      } = item;
    Severity: Minor
    Found in src/formatters/simple.js - About 1 hr to fix

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

      const compareData = (data1, data2) => getSortedKeys(data1, data2).map((key) => {
        if (_.isObject(data1[key]) && _.isObject(data2[key])) {
          return { key, type: 'tree', children: compareData(data1[key], data2[key]) };
        }
        if (!_.has(data1, key)) {
      Severity: Minor
      Found in src/comparison.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

      Avoid too many return statements within this function.
      Open

        return {
          key, type: 'changed', oldValue: data1[key], newValue: data2[key],
        };
      Severity: Major
      Found in src/comparison.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return `Property '${currentKey}' was not changed`;
        Severity: Major
        Found in src/formatters/plain.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return `${oldItem}\n${newItem}`;
          Severity: Major
          Found in src/formatters/simple.js - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language