taye/interact.js

View on GitHub

Showing 163 of 163 total issues

Function install has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
Open

function install(scope: Scope) {
  const targets: Array<{
    eventTarget: PartialEventTarget
    events: { [type: string]: ListenerEntry[] }
  }> = []
Severity: Minor
Found in packages/@interactjs/core/events.ts - About 2 days 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

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 install has 204 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function install(scope: Scope) {
      const targets: Array<{
        eventTarget: PartialEventTarget
        events: { [type: string]: ListenerEntry[] }
      }> = []
    Severity: Major
    Found in packages/@interactjs/core/events.ts - About 1 day to fix

      Function createInteractStatic has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

      export function createInteractStatic(scope: Scope): InteractStatic {
        const interact = ((target: Target, options: Options) => {
          let interactable = scope.interactables.getExisting(target, options)
      
          if (!interactable) {
      Severity: Minor
      Found in packages/@interactjs/core/InteractStatic.ts - About 6 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 checkResizeEdge has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

      function checkResizeEdge(
        name: string,
        value: any,
        page: Point,
        element: Node,
      Severity: Minor
      Found in packages/@interactjs/actions/resize/plugin.ts - About 6 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

      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'
      Severity: Minor
      Found in packages/@interactjs/core/Interaction.ts - About 6 hrs to fix

        Function set has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

        function set(arg: ModifierArg<SnapState>) {
          const { interaction, coords, state } = arg
          const { options, offsets } = state
        
          const origin = getOriginXY(interaction.interactable!, interaction.element!, interaction.prepared.name)
        Severity: Minor
        Found in packages/@interactjs/modifiers/snap/pointer.ts - About 5 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 indexOfDeepestElement has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        export function indexOfDeepestElement(elements: Element[] | NodeListOf<globalThis.Element>) {
          let deepestNodeParents: Node[] = []
          let deepestNodeIndex: number
        
          for (let i = 0; i < elements.length; i++) {
        Severity: Minor
        Found in packages/@interactjs/utils/domUtils.ts - About 5 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

        File plugin.ts has 378 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 } from '@interactjs/core/Interaction'
        import type { PerActionDefaults } from '@interactjs/core/options'
        import type { Scope, Plugin } from '@interactjs/core/scope'
        Severity: Minor
        Found in packages/@interactjs/actions/resize/plugin.ts - About 5 hrs 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 createInteractStatic has 109 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function createInteractStatic(scope: Scope): InteractStatic {
            const interact = ((target: Target, options: Options) => {
              let interactable = scope.interactables.getExisting(target, options)
          
              if (!interactable) {
          Severity: Major
          Found in packages/@interactjs/core/InteractStatic.ts - About 4 hrs to fix

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

            import type { Interaction, DoPhaseArg } from '@interactjs/core/Interaction'
            import type { Scope, SignalArgs, Plugin } from '@interactjs/core/scope'
            import type { ActionName, Point, PointerEventType } from '@interactjs/core/types'
            /* eslint-disable import/no-duplicates -- for typescript module augmentations */
            import '@interactjs/modifiers/base'
            Severity: Minor
            Found in packages/@interactjs/inertia/plugin.ts - About 4 hrs to fix

              File Modification.ts has 337 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import type { EventPhase } from '@interactjs/core/InteractEvent'
              import type { Interaction, DoAnyPhaseArg } from '@interactjs/core/Interaction'
              import type { EdgeOptions, FullRect, Point, Rect } from '@interactjs/core/types'
              import clone from '@interactjs/utils/clone'
              import extend from '@interactjs/utils/extend'
              Severity: Minor
              Found in packages/@interactjs/modifiers/Modification.ts - About 4 hrs to fix

                File base.ts has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import type { Interactable } from '@interactjs/core/Interactable'
                import type { Interaction } from '@interactjs/core/Interaction'
                import type { Scope, SignalArgs, Plugin } from '@interactjs/core/scope'
                import type {
                  CursorChecker,
                Severity: Minor
                Found in packages/@interactjs/auto-start/base.ts - About 3 hrs to fix

                  File Interactable.ts has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /* eslint-disable no-dupe-class-members */
                  import * as arr from '@interactjs/utils/arr'
                  import browser from '@interactjs/utils/browser'
                  import clone from '@interactjs/utils/clone'
                  import { getElementRect, matchesUpTo, nodeContains, trySelector } from '@interactjs/utils/domUtils'
                  Severity: Minor
                  Found in packages/@interactjs/core/Interactable.ts - About 3 hrs to fix

                    File base.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import type { Eventable } from '@interactjs/core/Eventable'
                    import type { Interaction } from '@interactjs/core/Interaction'
                    import type { PerActionDefaults } from '@interactjs/core/options'
                    import type { Scope, SignalArgs, Plugin } from '@interactjs/core/scope'
                    import type { Point, PointerType, PointerEventType, Element } from '@interactjs/core/types'
                    Severity: Minor
                    Found in packages/@interactjs/pointer-events/base.ts - About 3 hrs to fix

                      Function _onOff has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                      Open

                        _onOff(
                          method: OnOffMethod,
                          typeArg: EventTypes,
                          listenerArg?: ListenersArg | null,
                          options?: any,
                      Severity: Minor
                      Found in packages/@interactjs/core/Interactable.ts - About 3 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 resizeChecker has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function resizeChecker(arg) {
                        const { interaction, interactable, element, rect, buttons } = arg
                      
                        if (!rect) {
                          return undefined
                      Severity: Minor
                      Found in packages/@interactjs/actions/resize/plugin.ts - About 3 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 beforeStart has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function beforeStart({ interaction, eventTarget, dx, dy }: SignalArgs['interactions:move'], scope: Scope) {
                        if (interaction.prepared.name !== 'drag') return
                      
                        // check if a drag is in the correct axis
                        const absX = Math.abs(dx)
                      Severity: Minor
                      Found in packages/@interactjs/auto-start/dragAxis.ts - About 3 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 start has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                        start(arg) {
                          const { state, rect, edges, pageCoords: coords } = arg
                          let { ratio, enabled } = state.options
                          const { equalDelta, modifiers } = state.options
                      
                      
                      Severity: Minor
                      Found in packages/@interactjs/modifiers/aspectRatio.ts - About 3 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

                      Severity
                      Category
                      Status
                      Source
                      Language