taye/interact.js

View on GitHub

Showing 142 of 156 total issues

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

function doOnInteractions (method, scope) {
  return function (event) {
    const interactions = scope.interactions.list

    const pointerType = pointerUtils.getPointerType(event)
Severity: Major
Found in packages/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 signals = new Signals()
    
      const listeners = {} as any
    
    
    Severity: Minor
    Found in packages/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

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

    function withinInteractionLimit (interactable: Interact.Interactable, element: Element, action, scope: Interact.Scope) {
      const options = interactable.options
      const maxActions = options[action.name].max
      const maxPerElement = options[action.name].maxPerElement
      const autoStartMax = scope.autoStart.maxInteractions
    Severity: Minor
    Found in packages/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 init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function init (window) {
      const Element = domObjects.Element
      const navigator  = win.window.navigator
    
      // Does the browser support touch input?
    Severity: Minor
    Found in packages/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 constructor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

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

        InteractEvent has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class InteractEvent<
          T extends ActionName = any,
          P extends EventPhase = EventPhase._NONE,
        > extends BaseEvent<T> {
          target: Element
        Severity: Minor
        Found in packages/core/InteractEvent.ts - About 2 hrs to fix

          Function reflow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function reflow (interactable: Interactable, action: ActionProps, scope: Scope): Promise<Interactable> {
            const elements = is.string(interactable.target)
              ? arr.from(interactable._context.querySelectorAll(interactable.target))
              : [interactable.target]
          
          
          Severity: Minor
          Found in packages/reflow/index.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 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/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 setAll has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function setAll (arg: Partial<Interact.SignalArg>) {
            const {
              interaction,
              modifiersState = interaction.modifiers,
              prevCoords = modifiersState.result
          Severity: Major
          Found in packages/modifiers/base.ts - About 2 hrs to fix

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

            import { PerActionDefaults } from '@interactjs/core/defaultOptions'
            import Eventable from '@interactjs/core/Eventable'
            import Interaction from '@interactjs/core/Interaction'
            import { Scope } from '@interactjs/core/scope'
            import * as utils from '@interactjs/utils'
            Severity: Minor
            Found in packages/pointer-events/base.ts - About 2 hrs to fix

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

              function install (scope: Scope) {
                const {
                  pointerEvents,
                  actions,
                  Interactable,
              Severity: Major
              Found in packages/pointer-events/interactableTargets.ts - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                  if (resizeOptions.square || resizeOptions.preserveAspectRatio) {
                    const linkedEdges = extend({}, interaction.prepared.edges)
                
                    linkedEdges.top    = linkedEdges.top    || (linkedEdges.left   && !linkedEdges.bottom)
                    linkedEdges.left   = linkedEdges.left   || (linkedEdges.top    && !linkedEdges.right)
                Severity: Critical
                Found in packages/actions/resize.ts - About 2 hrs to fix

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

                  function fire<T extends string> (arg: {
                    interaction: Interaction
                    pointer: Interact.PointerType
                    event: Interact.PointerEventType
                    eventTarget: Interact.EventTarget
                  Severity: Minor
                  Found in packages/pointer-events/base.ts - About 1 hr to fix

                    Function delegateListener has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function delegateListener (event: Event, optionalArg?: any) {
                      const options = getOptions(optionalArg)
                      const fakeEvent = new FakeEvent(event)
                      const delegated = delegatedEvents[event.type]
                      const [eventTarget] = (pointerUtils.getEventTargets(event))
                    Severity: Minor
                    Found in packages/utils/events.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: Interact.EventTypes,
                      listeners?: Interact.ListenersArg | Interact.ListenersArg[],
                      result?: NormalizedListeners,
                    ): NormalizedListeners {
                    Severity: Minor
                    Found in packages/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 getDropEvents has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function getDropEvents (interaction: Interact.Interaction, _pointerEvent, dragEvent) {
                      const { dropState } = interaction
                      const dropEvents = {
                        enter     : null,
                        leave     : null,
                    Severity: Minor
                    Found in packages/actions/drop/index.ts - About 1 hr to fix

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

                      function install (scope: Scope) {
                        scope.autoStart.signals.on('before-start',  ({ interaction, eventTarget, dx, dy }) => {
                          if (interaction.prepared.name !== 'drag') { return }
                      
                          // check if a drag is in the correct axis
                      Severity: Minor
                      Found in packages/auto-start/dragAxis.ts - About 1 hr to fix

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

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

                          Function setPerAction has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                            setPerAction (actionName, options: Interact.OrBoolean<Options>) {
                              const defaults = this._defaults
                          
                              // for all the default per-action options
                              for (const optionName in options) {
                          Severity: Minor
                          Found in packages/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

                          Severity
                          Category
                          Status
                          Source
                          Language