peter/jsonapitest

View on GitHub
lib/util.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function nestedValue has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var nestedValue = (function() {
  var assertValidArgs = function(hash, nestedKey) {
    if (hash == null || typeof hash !== 'object') {
      throw new UtilError('nested_value_invalid_hash', 'Expected object as hash argument but got ' + hash + " nestedKey=" + nestedKey);
    }
Severity: Minor
Found in lib/util.js - About 1 hr to fix

    Function equalValues has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    var equalValues = function(value1, value2) {
      if (value1 == null && value2 == null) {
        // both values are null/undefined
        return true;
      } else if (_.isRegExp(value2) && !_.isRegExp(value1)) {
    Severity: Minor
    Found in lib/util.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

    Consider simplifying this complex logical expression.
    Open

        if (value1 && value2 && (_.isObject(value1) && !_.isArray(value1)) && (_.isObject(value2) && !_.isArray(value2))) {
            result[key] = deepMerge(value1, value2);
        } else {
          result[key] = (value2 === undefined ? value1 : value2);
          if (result[key] && _.isObject(result[key])) result[key] = _.cloneDeep(result[key]);
    Severity: Major
    Found in lib/util.js - About 40 mins to fix

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

      var nestedValue = (function() {
        var assertValidArgs = function(hash, nestedKey) {
          if (hash == null || typeof hash !== 'object') {
            throw new UtilError('nested_value_invalid_hash', 'Expected object as hash argument but got ' + hash + " nestedKey=" + nestedKey);
          }
      Severity: Minor
      Found in lib/util.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

            return value1.toString() === value2.toString();
      Severity: Major
      Found in lib/util.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

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

          Avoid too many return statements within this function.
          Open

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

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

            var prepareStringify = function(object) {
              if (isIterable(object)) {
                Object.keys(object).forEach(function(key) {
                  var value = object[key];
                  if (_.isRegExp(value)) {
            Severity: Minor
            Found in lib/util.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