taye/interact.js

View on GitHub
packages/@interactjs/actions/drop/plugin.ts

Summary

Maintainability
F
3 days
Test Coverage

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'
Severity: Major
Found in packages/@interactjs/actions/drop/plugin.ts - About 1 day to fix

    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) {
    Severity: Minor
    Found in packages/@interactjs/actions/drop/plugin.ts - About 4 hrs to fix

    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) {
    Severity: Major
    Found in packages/@interactjs/actions/drop/plugin.ts - About 2 hrs to fix

      Function dropCheckMethod has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function dropCheckMethod(
        interactable: Interactable,
        dragEvent: InteractEvent,
        event: PointerEventType,
        draggable: Interactable,
      Severity: Minor
      Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

        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) {
        Severity: Minor
        Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

        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,
        Severity: Minor
        Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

          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)
          
          
          Severity: Minor
          Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

            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,
            Severity: Minor
            Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

            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,
            Severity: Minor
            Found in packages/@interactjs/actions/drop/plugin.ts - About 55 mins to fix

            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,
            Severity: Major
            Found in packages/@interactjs/actions/drop/plugin.ts - About 50 mins to fix

              Function dropCheckMethod has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                interactable: Interactable,
                dragEvent: InteractEvent,
                event: PointerEventType,
                draggable: Interactable,
                draggableElement: Element,
              Severity: Major
              Found in packages/@interactjs/actions/drop/plugin.ts - About 50 mins to fix

                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 }))
                    ) {
                Severity: Major
                Found in packages/@interactjs/actions/drop/plugin.ts - About 40 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status