inversify/inversify-express-utils

View on GitHub

Showing 14 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 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 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 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

                  Similar blocks of code found in 5 locations. Consider refactoring.
                  Open

                  export class BadRequestResult implements IHttpActionResult {
                    public async executeAsync(): Promise<HttpResponseMessage> {
                      return Promise.resolve(new HttpResponseMessage(StatusCodes.BAD_REQUEST));
                    }
                  }
                  Severity: Major
                  Found in src/results/BadRequestResult.ts and 4 other locations - About 50 mins to fix
                  src/results/ConflictResult.ts on lines 5..9
                  src/results/InternalServerError.ts on lines 5..11
                  src/results/NotFoundResult.ts on lines 5..11
                  src/results/OkResult.ts on lines 5..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 5 locations. Consider refactoring.
                  Open

                  export class InternalServerErrorResult implements IHttpActionResult {
                    public async executeAsync(): Promise<HttpResponseMessage> {
                      return Promise.resolve(
                        new HttpResponseMessage(StatusCodes.INTERNAL_SERVER_ERROR)
                      );
                  Severity: Major
                  Found in src/results/InternalServerError.ts and 4 other locations - About 50 mins to fix
                  src/results/BadRequestResult.ts on lines 5..9
                  src/results/ConflictResult.ts on lines 5..9
                  src/results/NotFoundResult.ts on lines 5..11
                  src/results/OkResult.ts on lines 5..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 5 locations. Consider refactoring.
                  Open

                  export class ConflictResult implements IHttpActionResult {
                    public async executeAsync(): Promise<HttpResponseMessage> {
                      return Promise.resolve(new HttpResponseMessage(StatusCodes.CONFLICT));
                    }
                  }
                  Severity: Major
                  Found in src/results/ConflictResult.ts and 4 other locations - About 50 mins to fix
                  src/results/BadRequestResult.ts on lines 5..9
                  src/results/InternalServerError.ts on lines 5..11
                  src/results/NotFoundResult.ts on lines 5..11
                  src/results/OkResult.ts on lines 5..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 5 locations. Consider refactoring.
                  Open

                  export class OkResult implements IHttpActionResult {
                    public async executeAsync(): Promise<HttpResponseMessage> {
                      return Promise.resolve(
                        new HttpResponseMessage(StatusCodes.OK)
                      );
                  Severity: Major
                  Found in src/results/OkResult.ts and 4 other locations - About 50 mins to fix
                  src/results/BadRequestResult.ts on lines 5..9
                  src/results/ConflictResult.ts on lines 5..9
                  src/results/InternalServerError.ts on lines 5..11
                  src/results/NotFoundResult.ts on lines 5..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 5 locations. Consider refactoring.
                  Open

                  export class NotFoundResult implements IHttpActionResult {
                    public async executeAsync(): Promise<HttpResponseMessage> {
                      return Promise.resolve(
                        new HttpResponseMessage(StatusCodes.NOT_FOUND)
                      );
                  Severity: Major
                  Found in src/results/NotFoundResult.ts and 4 other locations - About 50 mins to fix
                  src/results/BadRequestResult.ts on lines 5..9
                  src/results/ConflictResult.ts on lines 5..9
                  src/results/InternalServerError.ts on lines 5..11
                  src/results/OkResult.ts on lines 5..11

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 52.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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