taye/interact.js

View on GitHub
packages/@interactjs/auto-start/base.ts

Summary

Maintainability
C
1 day
Test Coverage

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

    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 withinInteractionLimit has 34 lines of code (exceeds 25 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 1 hr to fix

      Function getActionInfo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getActionInfo(
        interaction: Interaction,
        pointer: PointerType,
        event: PointerEventType,
        eventTarget: Node,
      Severity: Minor
      Found in packages/@interactjs/auto-start/base.ts - About 1 hr to fix

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

          interaction: Interaction,
          pointer: PointerType,
          event: PointerEventType,
          matches: Interactable[],
          matchElements: Element[],
        Severity: Major
        Found in packages/@interactjs/auto-start/base.ts - About 50 mins to fix

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

          function setInteractionCursor<T extends ActionName>(interaction: Interaction<T>, scope: Scope) {
            const { interactable, element, prepared } = interaction
          
            if (!(interaction.pointerType === 'mouse' && interactable && interactable.options.styleCursor)) {
              // clear previous target element cursor
          Severity: Minor
          Found in packages/@interactjs/auto-start/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 startOnMove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function startOnMove(arg: SignalArgs['interactions:move'], scope: Scope) {
            const { interaction } = arg
          
            if (
              !interaction.pointerIsDown ||
          Severity: Minor
          Found in packages/@interactjs/auto-start/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 validateAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            action: ActionProps<T>,
            interactable: Interactable,
            element: Element,
            eventTarget: Node,
            scope: Scope,
          Severity: Minor
          Found in packages/@interactjs/auto-start/base.ts - About 35 mins to fix

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

              interaction: Interaction,
              pointer: PointerType,
              event: PointerEventType,
              eventTarget: Node,
              scope: Scope,
            Severity: Minor
            Found in packages/@interactjs/auto-start/base.ts - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                return autoStartMax > 0
              Severity: Major
              Found in packages/@interactjs/auto-start/base.ts - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status