File plugin.ts
has 509 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { Interactable } from '@interactjs/core/Interactable'
import type { EventPhase, InteractEvent } from '@interactjs/core/InteractEvent'
import type { Interaction, DoPhaseArg } from '@interactjs/core/Interaction'
import type { PerActionDefaults } from '@interactjs/core/options'
import type { Scope, Plugin } from '@interactjs/core/scope'
Function dropzoneMethod
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
function dropzoneMethod(interactable: Interactable, options?: DropzoneOptions | boolean) {
if (is.object(options)) {
interactable.options.drop.enabled = options.enabled !== false
if (options.listeners) {
- 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 dropzoneMethod
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dropzoneMethod(interactable: Interactable, options?: DropzoneOptions | boolean) {
if (is.object(options)) {
interactable.options.drop.enabled = options.enabled !== false
if (options.listeners) {
Function dropCheckMethod
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dropCheckMethod(
interactable: Interactable,
dragEvent: InteractEvent,
event: PointerEventType,
draggable: Interactable,
Function collectDropzones
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function collectDropzones({ interactables }: Scope, draggableElement: Element) {
const drops: ActiveDrop[] = []
// collect all dropzones and their elements which qualify for a drop
for (const dropzone of interactables.list) {
- 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 getDropEvents
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getDropEvents(interaction: Interaction, _pointerEvent, dragEvent: DragEvent) {
const dropState = interaction.dropState!
const dropEvents: Record<string, DropEvent | null> = {
enter: null,
leave: null,
Function install
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function install(scope: Scope) {
const { actions, interactStatic: interact, Interactable, defaults } = scope
scope.usePlugin(drag)
Function getDropEvents
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function getDropEvents(interaction: Interaction, _pointerEvent, dragEvent: DragEvent) {
const dropState = interaction.dropState!
const dropEvents: Record<string, DropEvent | null> = {
enter: null,
leave: null,
- 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 dropCheckMethod
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function dropCheckMethod(
interactable: Interactable,
dragEvent: InteractEvent,
event: PointerEventType,
draggable: Interactable,
- 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 dropCheck
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
this: Interactable,
dragEvent,
event,
draggable,
draggableElement,
Function dropCheckMethod
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
interactable: Interactable,
dragEvent: InteractEvent,
event: PointerEventType,
draggable: Interactable,
draggableElement: Element,
Consider simplifying this complex logical expression. Open
if (
(is.element(accept) && accept !== draggableElement) ||
(is.string(accept) && !domUtils.matchesSelector(draggableElement, accept)) ||
(is.func(accept) && !accept({ dropzone, draggableElement }))
) {