taye/interact.js

View on GitHub

Showing 142 of 156 total issues

Avoid deeply nested control flow statements.
Open

        for (const name of Object.keys(deps).filter(n => /@?interactjs\//.test(n))) {
          if (deps[name] === oldVersion) {
            deps[name] = newVersion
          } else {
            console.warn(`${file}: not updating "${name}" from "${deps[name]}"`)
Severity: Major
Found in scripts/version.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if (!listeners.length) {
                delegated.selectors.splice(index, 1)
                delegated.contexts.splice(index, 1)
                delegated.listeners.splice(index, 1)
    
    
    Severity: Major
    Found in packages/utils/events.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (capture === !!options.capture && passive === options.passive) {
                  fn(fakeEvent)
                }
      Severity: Major
      Found in packages/utils/events.ts - About 45 mins to fix

        Function defaultActionChecker has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function defaultActionChecker (interactable: Interactable, pointer: Interact.PointerType, event: Interact.PointerEventType, interaction: Interaction, element: Element, actions: Actions) {
        Severity: Minor
        Found in packages/auto-start/InteractableMethods.ts - About 45 mins to fix

          Function off has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            off (type: string, listener: Interact.ListenersArg) {
              const listeners = normalize(type, listener)
          
              for (type in listeners) {
                const eventList = this.types[type]
          Severity: Minor
          Found in packages/core/Eventable.ts - About 45 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 setAll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export function setAll (arg: Partial<Interact.SignalArg>) {
            const {
              interaction,
              modifiersState = interaction.modifiers,
              prevCoords = modifiersState.result
          Severity: Minor
          Found in packages/modifiers/base.ts - About 45 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 pointerMove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            pointerMove (pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Node) {
              if (!this.simulation && !(this.modifiers && this.modifiers.endPrevented)) {
                this.updatePointer(pointer, event, eventTarget, false)
                utils.pointer.setCoords(this.coords.cur, this.pointers.map(p => p.pointer), this._now())
              }
          Severity: Minor
          Found in packages/core/Interaction.ts - About 45 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

          Consider simplifying this complex logical expression.
          Open

                if (is.object(resizeOptions.edges)) {
                  for (const edge in resizeEdges) {
                    resizeEdges[edge] = checkResizeEdge(edge,
                      resizeOptions.edges[edge],
                      page,
          Severity: Major
          Found in packages/actions/resize.ts - About 40 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

              Consider simplifying this complex logical expression.
              Open

                  if (!closest.target || (inRange
                    // is the closest target in range?
                    ? (closest.inRange && range !== Infinity
                      // the pointer is relatively deeper in this target
                      ? distance / range < closest.distance / closest.range
              Severity: Major
              Found in packages/modifiers/snap/pointer.ts - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                      if (!browser.supportsPointerEvent && /mouse/.test(event.type)) {
                        // ignore mouse events while touch interactions are active
                        for (let i = 0; i < interactions.length && !invalidPointer; i++) {
                          invalidPointer = interactions[i].pointerType !== 'mouse' && interactions[i].pointerIsDown
                        }
                Severity: Major
                Found in packages/core/interactions.ts - About 40 mins to fix

                  Function checker has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    checker (_pointer, _event, _interactable, _element, interaction: { pointers: { length: number } }) {
                  Severity: Minor
                  Found in packages/actions/gesture.ts - About 35 mins to fix

                    Function getActionInfo has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function getActionInfo (interaction: Interact.Interaction, pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Element, scope: Interact.Scope) {
                    Severity: Minor
                    Found in packages/auto-start/base.ts - About 35 mins to fix

                      Function validateAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function validateAction (action, interactable, element, eventTarget, scope) {
                      Severity: Minor
                      Found in packages/auto-start/base.ts - About 35 mins to fix

                        Function getAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function getAction (this: Interactable, pointer: Interact.PointerType, event: Interact.PointerEventType, interaction: Interaction, element: Element): Interact.ActionProps {
                        Severity: Minor
                        Found in packages/auto-start/InteractableMethods.ts - About 35 mins to fix

                          Function removeDelegate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function removeDelegate (selector, context, type, listener?, optionalArg?: any) {
                          Severity: Minor
                          Found in packages/utils/events.ts - About 35 mins to fix

                            Function addDelegate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            function addDelegate (selector: string, context: Node, type: string, listener: Listener, optionalArg?: any) {
                            Severity: Minor
                            Found in packages/utils/events.ts - About 35 mins to fix

                              Function defaultActionChecker has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                Interactable.prototype.defaultActionChecker = function (this: Interactable, pointer, event, interaction, element) {
                              Severity: Minor
                              Found in packages/auto-start/InteractableMethods.ts - About 35 mins to fix

                                Function startReflow has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                function startReflow (scope: Scope, interactable: Interactable, element: Element, action: ActionProps, event: any) {
                                Severity: Minor
                                Found in packages/reflow/index.ts - About 35 mins to fix

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

                                  function set (arg: ModifierArg<RestrictSizeState>) {
                                    const { interaction, state } = arg
                                    const { options } = state
                                    const edges = interaction.prepared._linkedEdges || interaction.prepared.edges
                                  
                                  
                                  Severity: Minor
                                  Found in packages/modifiers/restrict/size.ts - About 35 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language