jashkenas/underscore

View on GitHub
modules/isEqual.js

Summary

Maintainability
D
2 days
Test Coverage

Function deepEq has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

function deepEq(a, b, aStack, bStack) {
  // Unwrap any wrapped objects.
  if (a instanceof _) a = a._wrapped;
  if (b instanceof _) b = b._wrapped;
  // Compare `[[Class]]` names.
Severity: Minor
Found in modules/isEqual.js - About 6 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 deepEq has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function deepEq(a, b, aStack, bStack) {
  // Unwrap any wrapped objects.
  if (a instanceof _) a = a._wrapped;
  if (b instanceof _) b = b._wrapped;
  // Compare `[[Class]]` names.
Severity: Major
Found in modules/isEqual.js - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor &&
                                 isFunction(bCtor) && bCtor instanceof bCtor)
                            && ('constructor' in a && 'constructor' in b)) {
          return false;
        }
    Severity: Major
    Found in modules/isEqual.js - About 1 hr to fix

      Function eq has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function eq(a, b, aStack, bStack) {
        // Identical objects are equal. `0 === -0`, but they aren't identical.
        // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
        if (a === b) return a !== 0 || 1 / a === 1 / b;
        // `null` or `undefined` only equal to itself (strict comparison).
      Severity: Minor
      Found in modules/isEqual.js - About 35 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

            if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
      Severity: Major
      Found in modules/isEqual.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              if (byteLength !== getByteLength(b)) return false;
        Severity: Major
        Found in modules/isEqual.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return deepEq(a, b, aStack, bStack);
          Severity: Major
          Found in modules/isEqual.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                if (aStack[length] === a) return bStack[length] === b;
            Severity: Major
            Found in modules/isEqual.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  if (length !== b.length) return false;
              Severity: Major
              Found in modules/isEqual.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
                Severity: Major
                Found in modules/isEqual.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      if (typeof a != 'object' || typeof b != 'object') return false;
                  Severity: Major
                  Found in modules/isEqual.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return false;
                    Severity: Major
                    Found in modules/isEqual.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return true;
                      Severity: Major
                      Found in modules/isEqual.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              if (!eq(a[length], b[length], aStack, bStack)) return false;
                        Severity: Major
                        Found in modules/isEqual.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              if (keys(b).length !== length) return false;
                          Severity: Major
                          Found in modules/isEqual.js - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status