src/routing/controllers/controller.loader.ts

Summary

Maintainability
A
2 hrs
Test Coverage
B
86%

Function bindHandler has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public bindHandler(target: IController, classType: Constructor, property: string, rawParams: FunctionParam[]): RequestHandler {
        const paramsGetter = buildParamsFunc(rawParams);

        return async (req, res) => {
            const ctrl: IController = Object.assign(new classType, target);
Severity: Minor
Found in src/routing/controllers/controller.loader.ts - About 1 hr to fix

    Function processBase has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public async processBase() {
            const auth = DependencyContainer.getContainer().getById("auth") as IAuth<object, object, IUser<object, object>>;
            const { app } = this.options;
    
            return async (classType: Constructor<IController>) => {
    Severity: Minor
    Found in src/routing/controllers/controller.loader.ts - About 1 hr to fix

      Function getSchemaDescriptor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          private getSchemaDescriptor(rawParams: FunctionParam[]) {
              const schema: RouteSchema = {};
      
              for (const { type } of rawParams) {
                  const md = metadata(type);
      Severity: Minor
      Found in src/routing/controllers/controller.loader.ts - About 35 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

      Calls to 'console.log' are not allowed.
      Open

                          console.log(error);

      Rule: no-console

      Bans the use of specified console methods.

      Rationale

      In general, console methods aren't appropriate for production code.

      Config

      A list of method names to ban. If no method names are provided, all console methods are banned.

      Examples
      "no-console": true,log,error
      Schema
      {
        "type": "array",
        "items": {
          "type": "string"
        }
      }

      For more information see this page.

      Parentheses are required when invoking a constructor
      Open

                  const ctrl: IController = Object.assign(new classType, target);

      Rule: new-parens

      Requires parentheses when invoking a constructor via the new keyword.

      Rationale

      Maintains stylistic consistency with other function calls.

      Config

      Not configurable.

      Examples
      "new-parens": true

      For more information see this page.

      There are no issues that match your filters.

      Category
      Status