taye/interact.js

View on GitHub
packages/actions/drop/index.ts

Summary

Maintainability
F
3 days
Test Coverage
D
69%

File index.ts has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Interactable from '@interactjs/core/Interactable'
import InteractEvent from '@interactjs/core/InteractEvent'
import { Scope } from '@interactjs/core/scope'
import * as utils from '@interactjs/utils'
import drag from '../drag'
Severity: Minor
Found in packages/actions/drop/index.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 (utils.is.object(options)) {
        interactable.options.drop.enabled = options.enabled !== false
    
        if (options.listeners) {
    Severity: Minor
    Found in packages/actions/drop/index.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 install has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function install (scope: Scope) {
      const {
        actions,
        /** @lends module:interact */
        interact,
    Severity: Major
    Found in packages/actions/drop/index.ts - About 3 hrs to fix

      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/actions/drop/index.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/actions/drop/index.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 (utils.is.object(options)) {
            interactable.options.drop.enabled = options.enabled !== false
        
            if (options.listeners) {
        Severity: Minor
        Found in packages/actions/drop/index.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/actions/drop/index.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/actions/drop/index.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: Interact.Interactable,
              dragEvent: InteractEvent,
              event: Interact.PointerEventType,
              draggable: Interact.Interactable,
            Severity: Minor
            Found in packages/actions/drop/index.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: Element,
            Severity: Major
            Found in packages/actions/drop/index.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/actions/drop/index.ts - About 50 mins to fix

                Consider simplifying this complex logical expression.
                Open

                    if ((utils.is.element(accept) && accept !== draggableElement) ||
                        (utils.is.string(accept) &&
                        !utils.dom.matchesSelector(draggableElement, accept)) ||
                        (utils.is.func(accept) && !accept({ dropzone, draggableElement }))) {
                      continue
                Severity: Major
                Found in packages/actions/drop/index.ts - About 40 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status