Showing 4 of 22 total issues
Function _attachRouteEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_attachRouteEvent(route: RoutableComponentRoute) {
const listener = (...args: any[]) => {
if (!this.controllers[route.controller]) {
if (!(route.controller in this.controllerClasses)) {
throw new Error(`controller [${route.controller}] not found`);
- 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
Function event
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
event(...args: string[]) {
if (this._currentFrom && this._currentController) {
if (args.length > 2) throw new Error("arguments too long");
this.eventOnFromController(args[0], args[1]);
} else if (this._currentFrom) {
- 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
Function unregisterComponent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
unregisterComponent(name: string) {
if (this.components[name] && this._listeners[name]) {
const listeners = this._listeners[name];
for (const event of Object.keys(listeners)) {
for (const listener of listeners[event]) {
- 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
Function _checkConstructorArguments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_checkConstructorArguments(from: string, event: string, controller: string, action: string) {
const isString = (obj: any) => typeof obj === "string" || obj instanceof String;
if (from == null) throw new Error("register routing error: from is empty!");
if (event == null) throw new Error("register routing error: event is empty!");
if (controller == null) throw new Error("register routing error: controller is empty!");
- 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"