src/routing/controllers/controller.loader.ts
Function bindHandler
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function processBase
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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>) => {
Function getSchemaDescriptor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
Wontfix
private getSchemaDescriptor(rawParams: FunctionParam[]) {
const schema: RouteSchema = {};
for (const { type } of rawParams) {
const md = metadata(type);
- 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
Calls to 'console.log' are not allowed. Open
Open
console.log(error);
- 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.
Parentheses are required when invoking a constructor Open
Open
const ctrl: IController = Object.assign(new classType, target);
- Read upRead up
- Exclude checks
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.