Showing 51 of 52 total issues

Function bindWorker has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private bindWorker(classType: Constructor, filePath: string, workerThreads: typeof import ("worker_threads")) {

        const instance = new classType();

        const storage: WorkerHandlers = [];
Severity: Minor
Found in src/worker/worker.loader.ts - About 1 hr to fix

    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 extractBase has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function extractBase(type: Constructor) {
            let base: any = { type: null };
        
            if (type === String) {
                base.type = "string";
        Severity: Minor
        Found in src/dto/dto.validator.ts - About 1 hr to fix

          Function buildSchema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function buildSchema(target: Constructor) {
              const instance = new target();
              const reflectedProperties = (getDtoProps(Object.getPrototypeOf(instance)));
          
              let requiredProperties = [...reflectedProperties];
          Severity: Minor
          Found in src/dto/dto.validator.ts - About 1 hr to fix

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

                    setScoped(id: string = "default", settings: TypelessComponentEntry<Constructor<T>> = {}) {
                        shortSet(classType, id, "scoped", settings);
                        return methods;
                    },
            Severity: Minor
            Found in src/dependency/dependency.utils.ts and 1 other location - About 55 mins to fix
            src/dependency/dependency.utils.ts on lines 33..36

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

            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

                    setSingleton(id: string = "default", settings: TypelessComponentEntry<Constructor<T>> = {}) {
                        shortSet(classType, id, "singleton", settings);
                        return methods;
                    },
            Severity: Minor
            Found in src/dependency/dependency.utils.ts and 1 other location - About 55 mins to fix
            src/dependency/dependency.utils.ts on lines 37..40

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

            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 extractBase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function extractBase(type: Constructor) {
                let base: any = { type: null };
            
                if (type === String) {
                    base.type = "string";
            Severity: Minor
            Found in src/dto/dto.validator.ts - About 55 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

            Function extractParamsAliases has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function extractParamsAliases(rawParams: FunctionParam[]) {
                const params = [];
            
                for (const { name, type } of rawParams) {
                    const md = metadata(type);
            Severity: Minor
            Found in src/comiler/binders.ts - About 55 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

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

            export function Forbidden<T = string>(subMessage?: T ): HttpMessage<T | undefined, 403, "text/plain"> {
                return createMessage(403, subMessage);
            }
            Severity: Major
            Found in src/http/message/index.ts and 2 other locations - About 55 mins to fix
            src/http/message/index.ts on lines 8..10
            src/http/message/index.ts on lines 16..18

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

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

            export function BadRequest<T = string>(body?: T): HttpMessage<T | undefined, 400, "text/plain"> {
                return createMessage(400, body);
            }
            Severity: Major
            Found in src/http/message/index.ts and 2 other locations - About 55 mins to fix
            src/http/message/index.ts on lines 12..14
            src/http/message/index.ts on lines 16..18

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

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

            export function NotFound<T = string>(body?: T): HttpMessage<T | undefined, 404, "text/plain"> {
                return createMessage(404, body);
            }
            Severity: Major
            Found in src/http/message/index.ts and 2 other locations - About 55 mins to fix
            src/http/message/index.ts on lines 8..10
            src/http/message/index.ts on lines 12..14

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

            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

            Consider simplifying this complex logical expression.
            Open

                    if (metadata(dependency).hasMetadata(INJECT_ID) || predefined) {
            
                        const id = depId ||
                                   metadata(Object.getPrototypeOf(parentObject), propertyKey).getMetadata(AUTOWIRED) ||
                                   metadata(dependency).getMetadata(INJECT_ID) ||
            Severity: Major
            Found in src/dependency/dependency.composer.ts - About 40 mins to fix

              Function proccessDependency has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private async proccessDependency(parentObject: Instance, dependency: Constructor, depId?: string, propertyKey?: string | symbol) {
                      // Check if there are any predefined/instantiated components of this type
                      const predefined = ComponentSettingsStorage.has(dependency) || this.container.contain(dependency);
              
                      if (metadata(dependency).hasMetadata(INJECT_ID) || predefined) {
              Severity: Minor
              Found in src/dependency/dependency.composer.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

              Function findExport has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function findExport(imp: any): any {
                  if (imp.default && isMainComponent(imp.default)) {
                      return imp.default;
                  }
              
              
              Severity: Minor
              Found in src/utils/directory.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

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

              function processProperty<T>(instance: Instance, propertyKey: string | symbol, objectPart: any, prototype: any) {
                  const type = reflectType(instance, propertyKey);
                  const sourceValue = objectPart[propertyKey];
                  const isPrimitive = [ Number, String, Boolean, Object ].includes(type);
              
              
              Severity: Minor
              Found in src/dto/dto.transformer.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

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

              export const ArrayOf = (targetClass: any ) => (target: Propotype, propertyKey: string | symbol) => {
                  const items =
                          isObject(targetClass) ? targetClass :
                          isFunction(targetClass) ? DtoSchemaStorage.get(targetClass) :
                          { type: targetClass.name.toLoweCase() };
              Severity: Minor
              Found in src/dto/dto.decorators.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

              Array type using 'Array<t>' is forbidden. Use 'T[]' instead.</t>
              Open

              export function reflectParameters(target: Instance, key?: string | symbol): Array<unknown> {
              Severity: Minor
              Found in src/utils/directory.loader.ts by tslint

              Rule: array-type

              Requires using either 'T[]' or 'Array<t>' for arrays.</t>

              Notes
              • TypeScript Only
              • Has Fix

              Config

              One of the following arguments must be provided:

              • "array" enforces use of T[] for all types T.
              • "generic" enforces use of Array<T> for all types T.
              • "array-simple" enforces use of T[] if T is a simple type (primitive or type reference).
              Examples
              "array-type": true,array
              "array-type": true,generic
              "array-type": true,array-simple
              Schema
              {
                "type": "string",
                "enum": [
                  "array",
                  "generic",
                  "array-simple"
                ]
              }

              For more information see this page.

              jsdoc is not formatted correctly on this line
              Open

                       *@deprecated
              Severity: Minor
              Found in src/auth/auth.types.ts by tslint

              Rule: jsdoc-format

              Enforces basic format rules for JSDoc comments.

              The following rules are enforced for JSDoc comments (comments starting with /**):

              • each line contains an asterisk and asterisks must be aligned
              • each asterisk must be followed by either a space or a newline (except for the first and the last)
              • the only characters before the asterisk on each line must be whitespace characters
              • one line comments must start with /** and end with */
              • multiline comments don't allow text after /** in the first line (with option "check-multiline-start")
              Rationale

              Helps maintain a consistent, readable style for JSDoc comments.

              Config

              You can optionally specify the option "check-multiline-start" to enforce the first line of a multiline JSDoc comment to be empty.

              Examples
              "jsdoc-format": true
              "jsdoc-format": true,check-multiline-start
              Schema
              {
                "type": "array",
                "minItems": 0,
                "maxItems": 1,
                "items": {
                  "type": "string",
                  "enum": [
                    "check-multiline-start"
                  ]
                }
              }

              For more information see this page.

              jsdoc is not formatted correctly on this line
              Open

                      *@member {string} - Max age of token
              Severity: Minor
              Found in src/auth/auth.types.ts by tslint

              Rule: jsdoc-format

              Enforces basic format rules for JSDoc comments.

              The following rules are enforced for JSDoc comments (comments starting with /**):

              • each line contains an asterisk and asterisks must be aligned
              • each asterisk must be followed by either a space or a newline (except for the first and the last)
              • the only characters before the asterisk on each line must be whitespace characters
              • one line comments must start with /** and end with */
              • multiline comments don't allow text after /** in the first line (with option "check-multiline-start")
              Rationale

              Helps maintain a consistent, readable style for JSDoc comments.

              Config

              You can optionally specify the option "check-multiline-start" to enforce the first line of a multiline JSDoc comment to be empty.

              Examples
              "jsdoc-format": true
              "jsdoc-format": true,check-multiline-start
              Schema
              {
                "type": "array",
                "minItems": 0,
                "maxItems": 1,
                "items": {
                  "type": "string",
                  "enum": [
                    "check-multiline-start"
                  ]
                }
              }

              For more information see this page.

              Severity
              Category
              Status
              Source
              Language