Yogu/site-manager

View on GitHub
src/objects.js

Summary

Maintainability
D
1 day
Test Coverage

Function extract has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

function extract(object, properties) {
    var dest = {};
    
    if (typeof properties == 'string')
        properties = [properties];
Severity: Minor
Found in src/objects.js - About 1 day 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 extract has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function extract(object, properties) {
    var dest = {};
    
    if (typeof properties == 'string')
        properties = [properties];
Severity: Major
Found in src/objects.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                if (name in object)
                    dest[name] = extract(object[name], specification);
    Severity: Major
    Found in src/objects.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (name.endsWith('[]')) {
                      name = name.substring(0, name.length - 2);
                      specification = { '[]': specification };
                  }
      Severity: Major
      Found in src/objects.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    for (name in object) {
                        if (name[0] == '_' || name in dest)
                            continue;
                        var result = extract(object[name], true /* only primitives */);
                        if (result !== null)
        Severity: Major
        Found in src/objects.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

              return dest;
          Severity: Major
          Found in src/objects.js - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status