luxe-eng/koa-spec

View on GitHub

Showing 24 of 24 total issues

Function createRequestValidator has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

function createRequestValidator(spec, method, route, parameterDefinitions) {
  function validateBoolean(name, type, format, value) {
    const actualValue = parseBoolean(value);

    if (!_.isBoolean(actualValue)) {
Severity: Minor
Found in lib/index.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 createRequestValidator has 265 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createRequestValidator(spec, method, route, parameterDefinitions) {
  function validateBoolean(name, type, format, value) {
    const actualValue = parseBoolean(value);

    if (!_.isBoolean(actualValue)) {
Severity: Major
Found in lib/index.js - About 1 day to fix

    File index.js has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const debug = require('debug')('koa-spec');
    const _ = require('lodash');
    const path = require('path');
    Severity: Minor
    Found in lib/index.js - About 5 hrs to fix

      Function createRouter has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      function createRouter(spec, options) {
        function getControllerMethod(controllerDirectory, controllerName, controllerMethodName, strictMode, method, route) {
          if (!controllerName) {
            throw new RouteError(method, route, `Controller name not specified. Specify via 'x-controller'.`);
          }
      Severity: Minor
      Found in lib/index.js - About 3 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 createRouter has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createRouter(spec, options) {
        function getControllerMethod(controllerDirectory, controllerName, controllerMethodName, strictMode, method, route) {
          if (!controllerName) {
            throw new RouteError(method, route, `Controller name not specified. Specify via 'x-controller'.`);
          }
      Severity: Major
      Found in lib/index.js - About 3 hrs to fix

        Function validateValueType has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          function validateValueType(name, type, format, nullable, items, properties, required, value) {
        Severity: Major
        Found in lib/index.js - About 1 hr to fix

          Function validateValue has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            function validateValue(name, type, format, nullable, items, properties, required, value) {
          Severity: Major
          Found in lib/index.js - About 1 hr to fix

            Function ValidationError has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function ValidationError(message, code, name, type, format, value) {
            Severity: Minor
            Found in lib/errors.js - About 45 mins to fix

              Function getControllerMethod has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                function getControllerMethod(controllerDirectory, controllerName, controllerMethodName, strictMode, method, route) {
              Severity: Minor
              Found in lib/index.js - About 45 mins to fix

                Function validateObject has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function validateObject(name, type, format, properties, required, value) {
                Severity: Minor
                Found in lib/index.js - About 45 mins to fix

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

                  function SourceValidationError(name, type, format, value, message) {
                  Severity: Minor
                  Found in lib/errors.js - About 35 mins to fix

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

                      function validateArray(name, type, format, items, values) {
                    Severity: Minor
                    Found in lib/index.js - About 35 mins to fix

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

                      function FormatValidationError(name, type, format, value, message) {
                      Severity: Minor
                      Found in lib/errors.js - About 35 mins to fix

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

                        function NullableValidationError(name, type, format, value, message) {
                        Severity: Minor
                        Found in lib/errors.js - About 35 mins to fix

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

                            function validateNumberDouble(name, type, format, value, actualValue) {
                          Severity: Minor
                          Found in lib/index.js - About 35 mins to fix

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

                              function validateStringUUID(name, type, format, value, actualValue) {
                            Severity: Minor
                            Found in lib/index.js - About 35 mins to fix

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

                              function TypeValidationError(name, type, format, value, message) {
                              Severity: Minor
                              Found in lib/errors.js - About 35 mins to fix

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

                                  function validateSchema(name, type, format, schema, value) {
                                Severity: Minor
                                Found in lib/index.js - About 35 mins to fix

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

                                    function validateIntegerInt32(name, type, format, value, actualValue) {
                                  Severity: Minor
                                  Found in lib/index.js - About 35 mins to fix

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

                                      function validateStringISBN(name, type, format, value, actualValue) {
                                    Severity: Minor
                                    Found in lib/index.js - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language