Showing 9 of 14 total issues
File server.ts
has 324 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import 'reflect-metadata';
import express, { Application, NextFunction, Request, RequestHandler, Response, Router } from 'express';
import { interfaces } from 'inversify';
import { BaseMiddleware, Controller } from './index';
Function getRouteInfo
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getRouteInfo(
container: inversifyInterfaces.Container,
): RouteInfo[] {
const raw = getRawMetadata(container);
Function registerControllers
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private registerControllers(): void {
// Fake HttpContext is needed during registration
this._container
.bind<HttpContext>(TYPE.HttpContext)
.toConstantValue({} as HttpContext);
Function endpoints
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const endpoints = r.methodMetadata.map(m => {
const method = m.method.toUpperCase();
const controllerPath = r.controllerMetadata.path;
const actionPath = m.path;
const paramMetadata = r.parameterMetadata;
Function extractParameters
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private extractParameters(
req: Request,
res: Response,
next: NextFunction,
params: ParameterMetadata[],
Function params
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function params(
type: PARAMETER_TYPE,
parameterName?: string | symbol
) {
return (
Function handlerFactory
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private handlerFactory(
controllerName: string,
key: string,
parameterMetadata: ParameterMetadata[],
): RequestHandler {
Function httpMethod
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function httpMethod(
method: keyof typeof HTTP_VERBS_ENUM,
path: string,
...middleware: Middleware[]
): HandlerDecorator {
Function getParam
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private getParam(
source: Request,
paramType: 'params' | 'query' | 'headers' | 'cookies',
injectRoot: boolean,
name?: string | symbol,
- 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"