taye/interact.js

View on GitHub

Showing 163 of 163 total issues

Avoid deeply nested control flow statements.
Open

            if (!listeners.length) {
              delegates.splice(index, 1)

              // remove delegate function from context
              remove(context, type, delegateListener)
Severity: Major
Found in packages/@interactjs/core/events.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (typeListeners.length === 0) {
                  delete target.events[type]
                  typeIsEmpty = true
                }
    Severity: Major
    Found in packages/@interactjs/core/events.ts - About 45 mins to fix

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

        start(event: PointerEventType) {
          const { interaction } = this
          const options = getOptions(interaction)
      
          if (!options || !options.enabled) {
      Severity: Minor
      Found in packages/@interactjs/inertia/plugin.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 (
                  t.isStringLiteral(key) &&
                  (!include || include.indexOf(key.value) !== -1) &&
                  (!exclude || exclude.indexOf(key.value) === -1)
                ) {
      Severity: Major
      Found in scripts/babel/inline-env-vars.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

          if (is.object(resizeOptions.edges)) {
            const resizeEdges = {
              left: false,
              right: false,
              top: false,
        Severity: Major
        Found in packages/@interactjs/actions/resize/plugin.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/@interactjs/core/interactions.ts - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if (
                  (is.element(accept) && accept !== draggableElement) ||
                  (is.string(accept) && !domUtils.matchesSelector(draggableElement, accept)) ||
                  (is.func(accept) && !accept({ dropzone, draggableElement }))
                ) {
            Severity: Major
            Found in packages/@interactjs/actions/drop/plugin.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
              Severity: Major
              Found in packages/@interactjs/modifiers/snap/pointer.ts - About 40 mins to fix

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

                    selector: string,
                    context: Node,
                    type: string,
                    listener: ListenerEntry['func'],
                    optionalArg?: any,
                Severity: Minor
                Found in packages/@interactjs/core/events.ts - About 35 mins to fix

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

                    Interactable.prototype._onOff = function (method, typeArg, listenerArg, options, filter) {
                  Severity: Minor
                  Found in packages/@interactjs/dev-tools/plugin.ts - About 35 mins to fix

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

                      scope: Scope,
                      interactable: Interactable,
                      element: Element,
                      action: ActionProps<T>,
                      event: any,
                    Severity: Minor
                    Found in packages/@interactjs/reflow/plugin.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

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

                            selector: string,
                            context: Document | Element,
                            type: string,
                            listener?: ListenerEntry['func'],
                            optionalArg?: any,
                        Severity: Minor
                        Found in packages/@interactjs/core/events.ts - About 35 mins to fix

                          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 defaultActionChecker has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              interactable: Interactable,
                              event: PointerEventType,
                              interaction: Interaction,
                              element: Element,
                              scope: Scope,
                            Severity: Minor
                            Found in packages/@interactjs/auto-start/InteractableMethods.ts - About 35 mins to fix

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

                                  this: Interactable,
                                  pointer: PointerType,
                                  event: PointerEventType,
                                  interaction: Interaction,
                                  element: Element,
                              Severity: Minor
                              Found in packages/@interactjs/auto-start/InteractableMethods.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, rect, edges } = arg
                                  const { options } = state
                                
                                  if (!edges) {
                                Severity: Minor
                                Found in packages/@interactjs/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

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

                                function updateGestureProps({ interaction, iEvent, phase }: GestureSignalArg) {
                                  if (interaction.prepared.name !== 'gesture') return
                                
                                  const pointers = interaction.pointers.map((p) => p.pointer)
                                  const starting = phase === 'start'
                                Severity: Minor
                                Found in packages/@interactjs/actions/gesture/plugin.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

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

                                async function main() {
                                  const sources = fileArgs.length ? fileArgs : await getSources()
                                
                                  console.log(`Linting ${sources.length} 'file${sources.length === 1 ? '' : 's'}...`)
                                
                                
                                Severity: Minor
                                Found in scripts/bin/lint.js - 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

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

                                export function getPointerType(pointer: { pointerType?: string; identifier?: number; type?: string }) {
                                  return is.string(pointer.pointerType)
                                    ? pointer.pointerType
                                    : is.number(pointer.pointerType)
                                      ? [undefined, undefined, 'touch', 'pen', 'mouse'][pointer.pointerType]!
                                Severity: Minor
                                Found in packages/@interactjs/utils/pointerUtils.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