Showing 24 of 24 total issues
Function createRequestValidator
has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring. Open
Open
function createRequestValidator(spec, method, route, parameterDefinitions) {
function validateBoolean(name, type, format, value) {
const actualValue = parseBoolean(value);
if (!_.isBoolean(actualValue)) {
- Read upRead up
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
Open
function createRequestValidator(spec, method, route, parameterDefinitions) {
function validateBoolean(name, type, format, value) {
const actualValue = parseBoolean(value);
if (!_.isBoolean(actualValue)) {
File index.js
has 388 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
'use strict';
const debug = require('debug')('koa-spec');
const _ = require('lodash');
const path = require('path');
Function createRouter
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
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'.`);
}
- Read upRead up
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
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'.`);
}
Function validateValueType
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateValueType(name, type, format, nullable, items, properties, required, value) {
Function validateValue
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateValue(name, type, format, nullable, items, properties, required, value) {
Function getControllerMethod
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function getControllerMethod(controllerDirectory, controllerName, controllerMethodName, strictMode, method, route) {
Function validateObject
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateObject(name, type, format, properties, required, value) {
Function ValidationError
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function ValidationError(message, code, name, type, format, value) {
Function NullableValidationError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function NullableValidationError(name, type, format, value, message) {
Function validateStringUUID
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateStringUUID(name, type, format, value, actualValue) {
Function validateStringDateTime
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateStringDateTime(name, type, format, value, actualValue) {
Function validateStringISBN
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateStringISBN(name, type, format, value, actualValue) {
Function FormatValidationError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function FormatValidationError(name, type, format, value, message) {
Function validateIntegerInt64
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateIntegerInt64(name, type, format, value, actualValue) {
Function TypeValidationError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function TypeValidationError(name, type, format, value, message) {
Function validateArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateArray(name, type, format, items, values) {
Function SourceValidationError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function SourceValidationError(name, type, format, value, message) {
Function validateSchema
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function validateSchema(name, type, format, schema, value) {