inversify/inversify-express-utils

View on GitHub

Showing 9 of 14 total issues

File server.ts has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import 'reflect-metadata';

import express, { Application, NextFunction, Request, RequestHandler, Response, Router } from 'express';
import { interfaces } from 'inversify';
import { BaseMiddleware, Controller } from './index';
Severity: Minor
Found in src/server.ts - About 3 hrs to fix

    Function getRouteInfo has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getRouteInfo(
      container: inversifyInterfaces.Container,
    ): RouteInfo[] {
      const raw = getRawMetadata(container);
    
    
    Severity: Major
    Found in src/debug.ts - About 2 hrs to fix

      Function registerControllers has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private registerControllers(): void {
          // Fake HttpContext is needed during registration
          this._container
            .bind<HttpContext>(TYPE.HttpContext)
            .toConstantValue({} as HttpContext);
      Severity: Major
      Found in src/server.ts - About 2 hrs to fix

        Function endpoints has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        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;
        Severity: Major
        Found in src/debug.ts - About 2 hrs to fix

          Function extractParameters has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private extractParameters(
              req: Request,
              res: Response,
              next: NextFunction,
              params: ParameterMetadata[],
          Severity: Minor
          Found in src/server.ts - About 1 hr to fix

            Function params has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function params(
              type: PARAMETER_TYPE,
              parameterName?: string | symbol
            ) {
              return (
            Severity: Minor
            Found in src/decorators.ts - About 1 hr to fix

              Function handlerFactory has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private handlerFactory(
                  controllerName: string,
                  key: string,
                  parameterMetadata: ParameterMetadata[],
                ): RequestHandler {
              Severity: Minor
              Found in src/server.ts - About 1 hr to fix

                Function httpMethod has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function httpMethod(
                  method: keyof typeof HTTP_VERBS_ENUM,
                  path: string,
                  ...middleware: Middleware[]
                ): HandlerDecorator {
                Severity: Minor
                Found in src/decorators.ts - About 1 hr to fix

                  Function getParam has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private getParam(
                      source: Request,
                      paramType: 'params' | 'query' | 'headers' | 'cookies',
                      injectRoot: boolean,
                      name?: string | symbol,
                  Severity: Minor
                  Found in src/server.ts - About 25 mins 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

                  Severity
                  Category
                  Status
                  Source
                  Language