src/dependency/dependency.composer.ts

Summary

Maintainability
A
1 hr
Test Coverage
B
86%

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

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

        private async injectByConstructor<T>(classType: Constructor<T>, ctrArgs: any[] = []): Promise<Array<unknown>> {

    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.

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

        private getInjectableProps(prototype: Constructor): Array<string | symbol> {

    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.

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

                console.log(`Unexpected dependency {${dependency}}`);

    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.

    There are no issues that match your filters.

    Category
    Status