inversify/inversify-express-utils

View on GitHub

Showing 22 of 22 total issues

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

import express, { Application, NextFunction, Request, RequestHandler, Response, Router } from 'express';
import { interfaces } from 'inversify';
import { BaseMiddleware, Controller } from './index';
import { getControllersFromMetadata, getControllersFromContainer, getControllerMetadata, getControllerMethodMetadata, getControllerParameterMetadata, instanceOfIHttpActionResult } from './utils';
import { TYPE, METADATA_KEY, DEFAULT_ROUTING_ROOT_PATH, PARAMETER_TYPE, DUPLICATED_CONTROLLER_NAME, } from './constants';
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,
    ): Array<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 50 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: Minor
        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: Array<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) {
              return (
                target: unknown | Controller,
                methodName: string | symbol,
                index: number
            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: Array<ParameterMetadata>,
                ): express.RequestHandler {
              Severity: Minor
              Found in src/server.ts - About 1 hr to fix

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

                export function httpMethod(
                  method: keyof typeof HTTP_VERBS_ENUM,
                  path: string,
                  ...middleware: Array<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 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 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 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

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

                  export function httpPatch(
                    path: string,
                    ...middleware: Array<Middleware>
                  ): HandlerDecorator {
                    return httpMethod('patch', path, ...middleware);
                  Severity: Major
                  Found in src/decorators.ts and 6 other locations - About 40 mins to fix
                  src/decorators.ts on lines 40..45
                  src/decorators.ts on lines 47..52
                  src/decorators.ts on lines 54..59
                  src/decorators.ts on lines 61..66
                  src/decorators.ts on lines 75..80
                  src/decorators.ts on lines 82..87

                  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 48.

                  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 7 locations. Consider refactoring.
                  Open

                  export function all(
                    path: string,
                    ...middleware: Array<Middleware>
                  ): HandlerDecorator {
                    return httpMethod('all', path, ...middleware);
                  Severity: Major
                  Found in src/decorators.ts and 6 other locations - About 40 mins to fix
                  src/decorators.ts on lines 47..52
                  src/decorators.ts on lines 54..59
                  src/decorators.ts on lines 61..66
                  src/decorators.ts on lines 68..73
                  src/decorators.ts on lines 75..80
                  src/decorators.ts on lines 82..87

                  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 48.

                  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 7 locations. Consider refactoring.
                  Open

                  export function httpPost(
                    path: string,
                    ...middleware: Array<Middleware>
                  ): HandlerDecorator {
                    return httpMethod('post', path, ...middleware);
                  Severity: Major
                  Found in src/decorators.ts and 6 other locations - About 40 mins to fix
                  src/decorators.ts on lines 40..45
                  src/decorators.ts on lines 47..52
                  src/decorators.ts on lines 61..66
                  src/decorators.ts on lines 68..73
                  src/decorators.ts on lines 75..80
                  src/decorators.ts on lines 82..87

                  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 48.

                  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 2 locations. Consider refactoring.
                  Open

                      const previousMetadata: Array<ControllerMetadata> = Reflect.getMetadata(
                        METADATA_KEY.controller,
                        Reflect,
                      ) as Array<ControllerMetadata> || [];
                  Severity: Minor
                  Found in src/decorators.ts and 1 other location - About 40 mins to fix
                  src/utils.ts on lines 19..23

                  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 48.

                  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 7 locations. Consider refactoring.
                  Open

                  export function httpGet(
                    path: string,
                    ...middleware: Array<Middleware>
                  ): HandlerDecorator {
                    return httpMethod('get', path, ...middleware);
                  Severity: Major
                  Found in src/decorators.ts and 6 other locations - About 40 mins to fix
                  src/decorators.ts on lines 40..45
                  src/decorators.ts on lines 54..59
                  src/decorators.ts on lines 61..66
                  src/decorators.ts on lines 68..73
                  src/decorators.ts on lines 75..80
                  src/decorators.ts on lines 82..87

                  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 48.

                  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 2 locations. Consider refactoring.
                  Open

                    const arrayOfControllerMetadata: Array<ControllerMetadata> =
                      Reflect.getMetadata(
                        METADATA_KEY.controller,
                        Reflect,
                      ) as Array<ControllerMetadata> || [];
                  Severity: Minor
                  Found in src/utils.ts and 1 other location - About 40 mins to fix
                  src/decorators.ts on lines 25..28

                  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 48.

                  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 7 locations. Consider refactoring.
                  Open

                  export function httpPut(
                    path: string,
                    ...middleware: Array<Middleware>
                  ): HandlerDecorator {
                    return httpMethod('put', path, ...middleware);
                  Severity: Major
                  Found in src/decorators.ts and 6 other locations - About 40 mins to fix
                  src/decorators.ts on lines 40..45
                  src/decorators.ts on lines 47..52
                  src/decorators.ts on lines 54..59
                  src/decorators.ts on lines 68..73
                  src/decorators.ts on lines 75..80
                  src/decorators.ts on lines 82..87

                  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 48.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language