taye/interact.js

View on GitHub

Showing 156 of 156 total issues

Function collectDrops has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function collectDrops ({ interactables }, draggableElement) {
  const drops = []

  // 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 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 set has 68 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 2 hrs to fix

    Function exports has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function (options) {
      const browserify = require('browserify')
      const plugins = (options.watch)
        ? [
          require('watchify'),
    Severity: Major
    Found in scripts/bundler.js - About 2 hrs to fix

      Function indexOfDeepestElement has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function indexOfDeepestElement (elements: Interact.Element[] | NodeListOf<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 = ActionName> {
          // current interactable being interacted with
          interactable: Interactable = 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: Interact.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: Interact.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

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

            function withinInteractionLimit<T extends Interact.ActionName> (
              interactable: Interact.Interactable,
              element: Interact.Element,
              action: Interact.ActionProps<T>,
              scope: Interact.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 init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            function init (window: any) {
              const Element = domObjects.Element
              const navigator  = win.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 constructor has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function _generate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function _generate (changedSources) {
                  for (const sourceFilename of changedSources) {
                    queue.add(async () => {
                      const shimResult = shim && await shim(sourceFilename)
                      const moduleName = getModuleName(sourceFilename)
              Severity: Major
              Found in scripts/esnext.js - About 2 hrs to fix

                Interactable has 21 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 Interactable.ts has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /* eslint-disable no-dupe-class-members */
                  import { ActionMap } from '@interactjs/core/scope'
                  import * as Interact from '@interactjs/types/index'
                  import * as arr from '@interactjs/utils/arr'
                  import browser from '@interactjs/utils/browser'
                  Severity: Minor
                  Found in packages/@interactjs/core/Interactable.ts - About 2 hrs to fix

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

                    function reflow<T extends Interact.ActionName> (interactable: Interactable, action: ActionProps<T>, scope: Scope): Promise<Interactable> {
                      const elements = (is.string(interactable.target)
                        ? arr.from(interactable._context.querySelectorAll(interactable.target))
                        : [interactable.target]) as Interact.Element[]
                    
                    
                    Severity: Minor
                    Found in packages/@interactjs/reflow/plugin.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/@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 fire has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function fire<T extends string> (
                      arg: {
                        pointer: Interact.PointerType | PointerEvent<any>
                        event: Interact.PointerEventType | PointerEvent<any>
                        eventTarget: Node
                    Severity: Major
                    Found in packages/@interactjs/pointer-events/base.ts - About 2 hrs to fix

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

                        start (event: Interact.PointerEventType) {
                          const { interaction } = this
                          const options = getOptions(interaction)
                      
                          if (!options || !options.enabled) {
                      Severity: Minor
                      Found in packages/@interactjs/inertia/plugin.ts - About 2 hrs to fix

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

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

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

                          function transformImportsToRelative () {
                            const resolve = require('resolve')
                          
                            const fixImportSource = ({ node: { source } }, { opts, filename }) => {
                              if (!source || (opts.ignore && opts.ignore(filename))) { return }
                          Severity: Minor
                          Found in scripts/utils.js - 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 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

                          Severity
                          Category
                          Status
                          Source
                          Language