taye/interact.js

View on GitHub
packages/@interactjs/core/Interaction.ts

Summary

Maintainability
D
1 day
Test Coverage

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

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

        pointerMove(pointer: PointerType, event: PointerEventType, eventTarget: Node) {
          if (!this.simulation && !(this.modification && this.modification.endResult)) {
            this.updatePointer(pointer, event, eventTarget, false)
          }
      
      
      Severity: Minor
      Found in packages/@interactjs/core/Interaction.ts - About 1 hr to fix

        Function updatePointer has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          updatePointer(pointer: PointerType, event: PointerEventType, eventTarget: Node, down?: boolean) {
            const id = pointerUtils.getPointerId(pointer)
            let pointerIndex = this.getPointerIndex(pointer)
            let pointerInfo = this.pointers[pointerIndex]
        
        
        Severity: Minor
        Found in packages/@interactjs/core/Interaction.ts - About 1 hr to fix

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

            pointerMove(pointer: PointerType, event: PointerEventType, eventTarget: Node) {
              if (!this.simulation && !(this.modification && this.modification.endResult)) {
                this.updatePointer(pointer, event, eventTarget, false)
              }
          
          
          Severity: Minor
          Found in packages/@interactjs/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

          Function start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            start<A extends ActionName>(action: ActionProps<A>, interactable: Interactable, element: Element): boolean {
              if (
                this.interacting() ||
                !this.pointerIsDown ||
                this.pointers.length < (action.name === 'gesture' ? 2 : 1) ||
          Severity: Minor
          Found in packages/@interactjs/core/Interaction.ts - About 25 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 updatePointer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            updatePointer(pointer: PointerType, event: PointerEventType, eventTarget: Node, down?: boolean) {
              const id = pointerUtils.getPointerId(pointer)
              let pointerIndex = this.getPointerIndex(pointer)
              let pointerInfo = this.pointers[pointerIndex]
          
          
          Severity: Minor
          Found in packages/@interactjs/core/Interaction.ts - About 25 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

          There are no issues that match your filters.

          Category
          Status