jashkenas/underscore

View on GitHub
underscore-esm.js

Summary

Maintainability
F
1 wk
Test Coverage

File underscore-esm.js has 1436 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//     Underscore.js 1.13.7
//     https://underscorejs.org
//     (c) 2009-2024 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
//     Underscore may be freely distributed under the MIT license.

Severity: Major
Found in underscore-esm.js - About 3 days to fix

    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 _$1) a = a._wrapped;
      if (b instanceof _$1) b = b._wrapped;
      // Compare `[[Class]]` names.
    Severity: Minor
    Found in underscore-esm.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 _$1) a = a._wrapped;
      if (b instanceof _$1) b = b._wrapped;
      // Compare `[[Class]]` names.
    Severity: Major
    Found in underscore-esm.js - About 2 hrs to fix

      Function throttle has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function throttle(func, wait, options) {
        var timeout, context, args, result;
        var previous = 0;
        if (!options) options = {};
      
      
      Severity: Minor
      Found in underscore-esm.js - About 2 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 uniq has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function uniq(array, isSorted, iteratee, context) {
        if (!isBoolean(isSorted)) {
          context = iteratee;
          iteratee = isSorted;
          isSorted = false;
      Severity: Minor
      Found in underscore-esm.js - About 2 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 flatten$1 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function flatten$1(input, depth, strict, output) {
        output = output || [];
        if (!depth && depth !== 0) {
          depth = Infinity;
        } else if (depth <= 0) {
      Severity: Minor
      Found in underscore-esm.js - About 2 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 createReduce has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function createReduce(dir) {
        // Wrap code that reassigns argument variables in a separate function than
        // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
        var reducer = function(obj, iteratee, memo, initial) {
          var _keys = !isArrayLike(obj) && keys(obj),
      Severity: Minor
      Found in underscore-esm.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 template has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function template(text, settings, oldSettings) {
        if (!settings && oldSettings) settings = oldSettings;
        settings = defaults({}, settings, _$1.templateSettings);
      
        // Combine delimiters into one regular expression via alternation.
      Severity: Minor
      Found in underscore-esm.js - About 1 hr to fix

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

        function debounce(func, wait, immediate) {
          var timeout, previous, args, result, context;
        
          var later = function() {
            var passed = now() - previous;
        Severity: Minor
        Found in underscore-esm.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 throttle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function throttle(func, wait, options) {
          var timeout, context, args, result;
          var previous = 0;
          if (!options) options = {};
        
        
        Severity: Minor
        Found in underscore-esm.js - About 1 hr to fix

          Function min has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function min(obj, iteratee, context) {
            var result = Infinity, lastComputed = Infinity,
                value, computed;
            if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
              obj = isArrayLike(obj) ? obj : values(obj);
          Severity: Minor
          Found in underscore-esm.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 result has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function result(obj, path, fallback) {
            path = toPath(path);
            var length = path.length;
            if (!length) {
              return isFunction$1(fallback) ? fallback.call(obj) : fallback;
          Severity: Minor
          Found in underscore-esm.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 intersection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function intersection(array) {
            var result = [];
            var argsLength = arguments.length;
            for (var i = 0, length = getLength(array); i < length; i++) {
              var item = array[i];
          Severity: Minor
          Found in underscore-esm.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 max has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function max(obj, iteratee, context) {
            var result = -Infinity, lastComputed = -Infinity,
                value, computed;
            if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
              obj = isArrayLike(obj) ? obj : values(obj);
          Severity: Minor
          Found in underscore-esm.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 debounce has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function debounce(func, wait, immediate) {
            var timeout, previous, args, result, context;
          
            var later = function() {
              var passed = now() - previous;
          Severity: Minor
          Found in underscore-esm.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

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

              Function pick has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              var pick = restArguments(function(obj, keys) {
                var result = {}, iteratee = keys[0];
                if (obj == null) return result;
                if (isFunction$1(iteratee)) {
                  if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
              Severity: Minor
              Found in underscore-esm.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

              Function template has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function template(text, settings, oldSettings) {
                if (!settings && oldSettings) settings = oldSettings;
                settings = defaults({}, settings, _$1.templateSettings);
              
                // Combine delimiters into one regular expression via alternation.
              Severity: Minor
              Found in underscore-esm.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

              Function executeBound has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
              Severity: Minor
              Found in underscore-esm.js - About 35 mins to fix

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

                function some(obj, predicate, context) {
                  predicate = cb(predicate, context);
                  var _keys = !isArrayLike(obj) && keys(obj),
                      length = (_keys || obj).length;
                  for (var index = 0; index < length; index++) {
                Severity: Minor
                Found in underscore-esm.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

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

                var partial = restArguments(function(func, boundArgs) {
                  var placeholder = partial.placeholder;
                  var bound = function() {
                    var position = 0, length = boundArgs.length;
                    var args = Array(length);
                Severity: Minor
                Found in underscore-esm.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 underscore-esm.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return false;
                  Severity: Major
                  Found in underscore-esm.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 underscore-esm.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 underscore-esm.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                          return true;
                        Severity: Major
                        Found in underscore-esm.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 underscore-esm.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                              return values(obj);
                            Severity: Major
                            Found in underscore-esm.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 underscore-esm.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 underscore-esm.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 underscore-esm.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                          if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
                                    Severity: Major
                                    Found in underscore-esm.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 underscore-esm.js - About 30 mins to fix

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

                                        function every(obj, predicate, context) {
                                          predicate = cb(predicate, context);
                                          var _keys = !isArrayLike(obj) && keys(obj),
                                              length = (_keys || obj).length;
                                          for (var index = 0; index < length; index++) {
                                        Severity: Minor
                                        Found in underscore-esm.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

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

                                        function each(obj, iteratee, context) {
                                          iteratee = optimizeCb(iteratee, context);
                                          var i, length;
                                          if (isArrayLike(obj)) {
                                            for (i = 0, length = obj.length; i < length; i++) {
                                        Severity: Minor
                                        Found in underscore-esm.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

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

                                        function keys(obj) {
                                          if (!isObject(obj)) return [];
                                          if (nativeKeys) return nativeKeys(obj);
                                          var keys = [];
                                          for (var key in obj) if (has$1(obj, key)) keys.push(key);
                                        Severity: Minor
                                        Found in underscore-esm.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

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

                                        function collectNonEnumProps(obj, keys) {
                                          keys = emulatedSet(keys);
                                          var nonEnumIdx = nonEnumerableProps.length;
                                          var constructor = obj.constructor;
                                          var proto = (isFunction$1(constructor) && constructor.prototype) || ObjProto;
                                        Severity: Minor
                                        Found in underscore-esm.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

                                        There are no issues that match your filters.

                                        Category
                                        Status