lib/RouteSchemaManager.js

Summary

Maintainability
F
4 days
Test Coverage

Function RouteSchemaManager has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
Open

var RouteSchemaManager = function(options) {
    options = options || {};

    var schemasByServerUri = {},
        validationTypes = {
Severity: Minor
Found in lib/RouteSchemaManager.js - About 2 days 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 RouteSchemaManager has 237 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var RouteSchemaManager = function(options) {
    options = options || {};

    var schemasByServerUri = {},
        validationTypes = {
Severity: Major
Found in lib/RouteSchemaManager.js - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

                if (forceArrayConversion && schema.type === 'array' && typeof(object) === 'string' && schema.items &&
                    (schema.items.type === 'string' || schema.items.type === 'number' || schema.items.type === 'integer' || schema.items.type === 'boolean')) {
                    object = [object];
                }
    Severity: Critical
    Found in lib/RouteSchemaManager.js - About 1 hr to fix

      Function convertPropertyTypesToMatchSchema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              convertPropertyTypesToMatchSchema = function(object, schema, forceArrayConversion) {
                  // in some cases (query params), we want to force a value to be an array that contains that value,
                  // if the schema expects an array of strings, numbers, integers, or booleans
                  if (forceArrayConversion && schema.type === 'array' && typeof(object) === 'string' && schema.items &&
                      (schema.items.type === 'string' || schema.items.type === 'number' || schema.items.type === 'integer' || schema.items.type === 'boolean')) {
      Severity: Minor
      Found in lib/RouteSchemaManager.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (schema.properties.hasOwnProperty(subProp)) {
                                        modifiedSchema.properties[subProp.toLowerCase()] = modifyHeadersSchema(schema.properties[subProp]);
                                    }
        Severity: Major
        Found in lib/RouteSchemaManager.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for (i = 0; i < object.length; i++) {
                                      object[i] = convertPropertyTypesToMatchSchema(object[i], schema.items, forceArrayConversion);
                                  }
          Severity: Major
          Found in lib/RouteSchemaManager.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

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

              There are no issues that match your filters.

              Category
              Status