taye/interact.js

View on GitHub

Showing 163 of 163 total issues

Function set has 76 lines of code (exceeds 25 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: Major
Found in packages/@interactjs/modifiers/snap/pointer.ts - About 3 hrs to fix

    Function install has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function install(scope: Scope) {
      const listeners = {} as any
    
      for (const method of methodNames) {
        listeners[method] = doOnInteractions(method, scope)
    Severity: Major
    Found in packages/@interactjs/core/interactions.ts - About 2 hrs to fix

      Function indexOfDeepestElement has 69 lines of code (exceeds 25 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: Major
      Found in packages/@interactjs/utils/domUtils.ts - About 2 hrs to fix

        Interaction has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class Interaction<T extends ActionName | null = ActionName> {
          /** current interactable being interacted with */
          interactable: Interactable | null = null
        
          /** the target element of the interactable */
        Severity: Minor
        Found in packages/@interactjs/core/Interaction.ts - About 2 hrs to fix

          Function doOnInteractions has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function doOnInteractions(method: string, scope: Scope) {
            return function (event: Event) {
              const interactions = scope.interactions.list
          
              const pointerType = pointerUtils.getPointerType(event)
          Severity: Major
          Found in packages/@interactjs/core/interactions.ts - About 2 hrs to fix

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

            function install(scope: Scope) {
              const listeners = {} as any
            
              for (const method of methodNames) {
                listeners[method] = doOnInteractions(method, scope)
            Severity: Minor
            Found in packages/@interactjs/core/interactions.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

            Interactable has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class Interactable implements Partial<Eventable> {
              /** @internal */ get _defaults(): Defaults {
                return {
                  base: {},
                  perAction: {},
            Severity: Minor
            Found in packages/@interactjs/core/Interactable.ts - About 2 hrs to fix

              File events.ts has 261 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import * as arr from '@interactjs/utils/arr'
              import * as domUtils from '@interactjs/utils/domUtils'
              import is from '@interactjs/utils/is'
              import pExtend from '@interactjs/utils/pointerExtend'
              import * as pointerUtils from '@interactjs/utils/pointerUtils'
              Severity: Minor
              Found in packages/@interactjs/core/events.ts - About 2 hrs to fix

                Function init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function init(window: any) {
                  const Element = domObjects.Element
                  const navigator: Partial<Navigator> = window.navigator || {}
                
                  // Does the browser support touch input?
                Severity: Minor
                Found in packages/@interactjs/utils/browser.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 withinInteractionLimit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                function withinInteractionLimit<T extends ActionName>(
                  interactable: Interactable,
                  element: Element,
                  action: ActionProps<T>,
                  scope: Scope,
                Severity: Minor
                Found in packages/@interactjs/auto-start/base.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 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 mouseOrPen has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                    mouseOrPen({ pointerId, pointerType, eventType, scope }: SearchDetails) {
                      if (pointerType !== 'mouse' && pointerType !== 'pen') {
                        return null
                      }
                  
                  
                  Severity: Minor
                  Found in packages/@interactjs/core/interactionFinder.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 constructor has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor(
                      interaction: Interaction<T>,
                      event: PointerEventType,
                      actionName: T,
                      phase: P,
                  Severity: Major
                  Found in packages/@interactjs/core/InteractEvent.ts - About 2 hrs to fix

                    Function resizeChecker has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function resizeChecker(arg) {
                      const { interaction, interactable, element, rect, buttons } = arg
                    
                      if (!rect) {
                        return undefined
                    Severity: Major
                    Found in packages/@interactjs/actions/resize/plugin.ts - About 2 hrs to fix

                      Function fire has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function fire<T extends string>(
                        arg: {
                          pointer: PointerType | PointerEvent<any>
                          event: PointerEventType | PointerEvent<any>
                          eventTarget: Node
                      Severity: Minor
                      Found in packages/@interactjs/pointer-events/base.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 unset has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                            unset() {
                              if (is.string(this.target)) {
                                // remove delegated events
                                for (const type in this._scopeEvents.delegatedEvents) {
                                  const delegated = this._scopeEvents.delegatedEvents[type]
                          Severity: Minor
                          Found in packages/@interactjs/core/Interactable.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 normalize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export default function normalize(
                            type: EventTypes,
                            listeners?: ListenersArg | ListenersArg[] | null,
                            filter = (_typeOrPrefix: string) => true,
                            result?: NormalizedListeners,
                          Severity: Minor
                          Found in packages/@interactjs/utils/normalizeListeners.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 doReflow has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function doReflow<T extends ActionName>(
                            interactable: Interactable,
                            action: ActionProps<T>,
                            scope: Scope,
                          ): Promise<Interactable> {
                          Severity: Minor
                          Found in packages/@interactjs/reflow/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 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

                          Severity
                          Category
                          Status
                          Source
                          Language