taye/interact.js

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

Summary

Maintainability
D
2 days
Test Coverage
C
78%

File plugin.ts has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { InteractEvent } from '@interactjs/core/InteractEvent'
import { Interactable } from '@interactjs/core/Interactable'
import * as Interact from '@interactjs/types/index'
import * as domUtils from '@interactjs/utils/domUtils'
import extend from '@interactjs/utils/extend'
Severity: Minor
Found in packages/@interactjs/actions/drop/plugin.ts - About 5 hrs to fix

    Function dropzoneMethod has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    function dropzoneMethod (interactable: Interact.Interactable, options?: Interact.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 collectDrops has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function collectDrops ({ interactables }, draggableElement) {
      const drops = []
    
      // 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 2 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 getDropEvents has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getDropEvents (interaction: Interact.Interaction, _pointerEvent, dragEvent) {
      const { dropState } = interaction
      const dropEvents = {
        enter     : null,
        leave     : null,
    Severity: Minor
    Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

      Function dropzoneMethod has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function dropzoneMethod (interactable: Interact.Interactable, options?: Interact.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 1 hr to fix

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

        function dropCheckMethod (
          interactable: Interact.Interactable,
          dragEvent: InteractEvent,
          event: Interact.PointerEventType,
          draggable: Interact.Interactable,
        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: Interact.Interaction, _pointerEvent, dragEvent) {
            const { dropState } = interaction
            const dropEvents = {
              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 install has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function install (scope: Interact.Scope) {
            const {
              actions,
              /** @lends module:interact */
              interactStatic: interact,
          Severity: Minor
          Found in packages/@interactjs/actions/drop/plugin.ts - About 1 hr to fix

            Function dropCheckMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function dropCheckMethod (
              interactable: Interact.Interactable,
              dragEvent: InteractEvent,
              event: Interact.PointerEventType,
              draggable: Interact.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 dropCheckMethod has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

                Interactable.prototype.dropCheck = function (this: Interact.Interactable, dragEvent, event, draggable, draggableElement, dropElement, rect) {
              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 }))) {
                      continue
                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