packages/@interactjs/core/events.ts
Function install
has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring. Open
Open
function install(scope: Scope) {
const targets: Array<{
eventTarget: PartialEventTarget
events: { [type: string]: ListenerEntry[] }
}> = []
- 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 install
has 204 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function install(scope: Scope) {
const targets: Array<{
eventTarget: PartialEventTarget
events: { [type: string]: ListenerEntry[] }
}> = []
File events.ts
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import * as arr from '@interactjs/utils/arr'
import * as domUtils from '@interactjs/utils/domUtils'
import is from '@interactjs/utils/is'
import pExtend from '@interactjs/utils/pointerExtend'
import * as pointerUtils from '@interactjs/utils/pointerUtils'
Function remove
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function remove(
eventTarget: PartialEventTarget,
type: string,
listener?: 'all' | ListenerEntry['func'],
optionalArg?: boolean | EventOptions,
Function removeDelegate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function removeDelegate(
selector: string,
context: Document | Element,
type: string,
listener?: ListenerEntry['func'],
Avoid deeply nested control flow statements. Open
Open
if (optionsMatch(entry.options, options)) {
entry.func(fakeEvent)
}
Avoid deeply nested control flow statements. Open
Open
if (!listeners.length) {
delegates.splice(index, 1)
// remove delegate function from context
remove(context, type, delegateListener)
Avoid deeply nested control flow statements. Open
Open
if (typeListeners.length === 0) {
delete target.events[type]
typeIsEmpty = true
}
Function addDelegate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
selector: string,
context: Node,
type: string,
listener: ListenerEntry['func'],
optionalArg?: any,
Function removeDelegate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
selector: string,
context: Document | Element,
type: string,
listener?: ListenerEntry['func'],
optionalArg?: any,