File EventDelegator.ts
has 530 lines of code (exceeds 250 allowed). Consider refactoring. Open
import xs, {Stream, Subscription} from 'xstream';
import {ScopeChecker} from './ScopeChecker';
import {IsolateModule} from './IsolateModule';
import {getSelectors, isEqualNamespace} from './utils';
import {ElementFinder} from './ElementFinder';
Function onEvent
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
private onEvent(
eventType: string,
event: Event,
passive: boolean,
bubbles = true
Function addEventListener
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public addEventListener(
eventType: string,
namespace: Array<Scope>,
options: EventsFnOptions,
bubbles?: boolean
Function addEventListener
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public addEventListener(
eventType: string,
namespace: Array<Scope>,
options: EventsFnOptions,
bubbles?: boolean
- 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 bubble
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private bubble(
eventType: string,
elm: Element,
rootElement: Element | undefined,
event: CycleDOMEvent,
Function setupNonBubblingListener
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private setupNonBubblingListener(
input: NonBubblingMeta
): void {
const [_, eventType, elementFinder, destination] = input;
if (!this.origin) {
Function removeElement
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public removeElement(element: Element, namespace?: Array<Scope>): void {
if (namespace !== undefined) {
this.virtualListeners.delete(namespace);
}
const toRemove: Array<[string, Element]> = [];
Function bubble
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private bubble(
eventType: string,
elm: Element,
rootElement: Element | undefined,
event: CycleDOMEvent,
- 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 getVirtualListeners
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private getVirtualListeners(
eventType: string,
namespace: Array<Scope>,
exact = false,
max?: number
- 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
Consider simplifying this complex logical expression. Open
if (
!event.propagationHasBeenStopped &&
dest.scopeChecker.isDirectlyInScope(elm) &&
((sel !== '' && elm.matches(sel)) ||
(sel === '' && elm === rootElement))
Function removeElement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public removeElement(element: Element, namespace?: Array<Scope>): void {
if (namespace !== undefined) {
this.virtualListeners.delete(namespace);
}
const toRemove: Array<[string, Element]> = [];
- 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"