src/utils/directory.loader.ts

Summary

Maintainability
A
35 mins
Test Coverage
B
87%

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

!= should be !==
Open

export const isFunction = (target: Instance, propertyKey: string | symbol) => (propertyKey && typeof (target as any)[propertyKey] == "function" && propertyKey != "constructor");
Severity: Minor
Found in src/utils/directory.loader.ts by tslint

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

block is empty
Open

        } else {}
Severity: Minor
Found in src/utils/directory.loader.ts by tslint

Rule: no-empty

Disallows empty blocks.

Blocks with a comment inside are not considered empty.

Rationale

Empty blocks are often indicators of missing code.

Config

If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

Examples
"no-empty": true
"no-empty": true,allow-empty-catch
"no-empty": true,allow-empty-functions
"no-empty": true,allow-empty-catch,allow-empty-functions
Schema
{
  "type": "array",
  "items": {
    "anyOf": [
      {
        "type": "string",
        "enum": [
          "allow-empty-catch"
        ]
      },
      {
        "type": "string",
        "enum": [
          "allow-empty-functions"
        ]
      }
    ]
  }
}

For more information see this page.

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.

== should be ===
Open

export const isFunction = (target: Instance, propertyKey: string | symbol) => (propertyKey && typeof (target as any)[propertyKey] == "function" && propertyKey != "constructor");
Severity: Minor
Found in src/utils/directory.loader.ts by tslint

Rule: triple-equals

Requires === and !== in place of == and !=.

Config

Two arguments may be optionally provided:

  • "allow-null-check" allows == and != when comparing to null.
  • "allow-undefined-check" allows == and != when comparing to undefined.
Examples
"triple-equals": true
"triple-equals": true,allow-null-check
"triple-equals": true,allow-undefined-check
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "allow-null-check",
      "allow-undefined-check"
    ]
  },
  "minLength": 0,
  "maxLength": 2
}

For more information see this page.

There are no issues that match your filters.

Category
Status