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) ||
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) {
- Read upRead up
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>> {
- Read upRead up
- Exclude checks
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 ofT[]
for all types T. -
"generic"
enforces use ofArray<T>
for all types T. -
"array-simple"
enforces use ofT[]
ifT
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> {
- Read upRead up
- Exclude checks
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 ofT[]
for all types T. -
"generic"
enforces use ofArray<T>
for all types T. -
"array-simple"
enforces use ofT[]
ifT
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}}`);
- Read upRead up
- Exclude checks
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.