File Interaction.ts
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as arr from '@interactjs/utils/arr'
import extend from '@interactjs/utils/extend'
import hypot from '@interactjs/utils/hypot'
import { warnOnce, copyAction } from '@interactjs/utils/misc'
import * as pointerUtils from '@interactjs/utils/pointerUtils'
Interaction
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
export class Interaction<T extends ActionName | null = ActionName> {
/** current interactable being interacted with */
interactable: Interactable | null = null
/** the target element of the interactable */
Function pointerMove
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
pointerMove(pointer: PointerType, event: PointerEventType, eventTarget: Node) {
if (!this.simulation && !(this.modification && this.modification.endResult)) {
this.updatePointer(pointer, event, eventTarget, false)
}
Function updatePointer
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
updatePointer(pointer: PointerType, event: PointerEventType, eventTarget: Node, down?: boolean) {
const id = pointerUtils.getPointerId(pointer)
let pointerIndex = this.getPointerIndex(pointer)
let pointerInfo = this.pointers[pointerIndex]
Function pointerMove
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
pointerMove(pointer: PointerType, event: PointerEventType, eventTarget: Node) {
if (!this.simulation && !(this.modification && this.modification.endResult)) {
this.updatePointer(pointer, event, eventTarget, false)
}
- 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 start
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
start<A extends ActionName>(action: ActionProps<A>, interactable: Interactable, element: Element): boolean {
if (
this.interacting() ||
!this.pointerIsDown ||
this.pointers.length < (action.name === 'gesture' ? 2 : 1) ||
- 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 updatePointer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
updatePointer(pointer: PointerType, event: PointerEventType, eventTarget: Node, down?: boolean) {
const id = pointerUtils.getPointerId(pointer)
let pointerIndex = this.getPointerIndex(pointer)
let pointerInfo = this.pointers[pointerIndex]
- 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"