taye/interact.js

View on GitHub

Showing 142 of 157 total issues

Function indexOfDeepestElement has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

export function indexOfDeepestElement (elements: Interact.Element[] | NodeListOf<Element>) {
  let deepestZoneParents = []
  let deepestZone = elements[0]
  let index = deepestZone ? 0 : -1
  let i
Severity: Minor
Found in packages/utils/domUtils.ts - About 5 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

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

import { Scope } from '@interactjs/core/scope'
import extend from '@interactjs/utils/extend'

declare module '@interactjs/core/scope' {
  interface Scope {
Severity: Minor
Found in packages/modifiers/base.ts - About 5 hrs to fix

    File index.ts has 376 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Interactable from '@interactjs/core/Interactable'
    import InteractEvent from '@interactjs/core/InteractEvent'
    import { Scope } from '@interactjs/core/scope'
    import * as utils from '@interactjs/utils'
    import drag from '../drag'
    Severity: Minor
    Found in packages/actions/drop/index.ts - About 5 hrs to fix

      File resize.ts has 374 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { ActionProps, Interaction } from '@interactjs/core/Interaction'
      import { ActionName, Scope } from '@interactjs/core/scope'
      import * as arr from '@interactjs/utils/arr'
      import * as dom from '@interactjs/utils/domUtils'
      import extend from '@interactjs/utils/extend'
      Severity: Minor
      Found in packages/actions/resize.ts - About 5 hrs to fix

        Function remove has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        function remove (element: EventTarget, type: string, listener?: 'all' | Listener, optionalArg?: boolean | any) {
          const options = getOptions(optionalArg)
          const elementIndex = elements.indexOf(element)
          const target = targets[elementIndex]
        
        
        Severity: Minor
        Found in packages/utils/events.ts - About 4 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 dropzoneMethod has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        function dropzoneMethod (interactable: Interact.Interactable, options?: Interact.DropzoneOptions | boolean) {
          if (utils.is.object(options)) {
            interactable.options.drop.enabled = options.enabled !== false
        
            if (options.listeners) {
        Severity: Minor
        Found in packages/actions/drop/index.ts - About 4 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

        File Interaction.ts has 343 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as utils from '@interactjs/utils'
        import Interactable from './Interactable'
        import InteractEvent, { EventPhase } from './InteractEvent'
        import PointerInfo from './PointerInfo'
        import { ActionName } from './scope'
        Severity: Minor
        Found in packages/core/Interaction.ts - About 4 hrs to fix

          Function move has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          function move ({ iEvent, interaction }: { iEvent: ResizeEvent, interaction: Interaction }) {
            if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) { return }
          
            const resizeOptions = interaction.interactable.options.resize
            const invert = resizeOptions.invert
          Severity: Minor
          Found in packages/actions/resize.ts - About 3 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 checker has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            checker (
              _pointer: Interact.PointerType,
              _event: Interact.PointerEventType,
              interactable: Interact.Interactable,
              element: Interact.Element,
          Severity: Minor
          Found in packages/actions/resize.ts - About 3 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 removeDelegate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

          function removeDelegate (selector, context, type, listener?, optionalArg?: any) {
            const options = getOptions(optionalArg)
            const delegated = delegatedEvents[type]
            let matchFound = false
            let index
          Severity: Minor
          Found in packages/utils/events.ts - About 3 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 install has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function install (scope: Scope) {
            const {
              actions,
              /** @lends module:interact */
              interact,
          Severity: Major
          Found in packages/actions/drop/index.ts - About 3 hrs to fix

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

            export function indexOfDeepestElement (elements: Interact.Element[] | NodeListOf<Element>) {
              let deepestZoneParents = []
              let deepestZone = elements[0]
              let index = deepestZone ? 0 : -1
              let i
            Severity: Major
            Found in packages/utils/domUtils.ts - About 3 hrs to fix

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

              function install (scope: Scope) {
                const {
                  interactions,
                } = scope
              
              
              Severity: Major
              Found in packages/pointer-events/base.ts - About 3 hrs to fix

                File index.ts has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { EventPhase } from '@interactjs/core/InteractEvent'
                import modifiers from '@interactjs/modifiers/base'
                import * as utils from '@interactjs/utils'
                import raf from '@interactjs/utils/raf'
                
                
                Severity: Minor
                Found in packages/inertia/index.ts - About 3 hrs to fix

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

                  function install (scope: Scope) {
                    const signals = new Signals()
                  
                    const listeners = {} as any
                  
                  
                  Severity: Major
                  Found in packages/core/interactions.ts - About 3 hrs to fix

                    Function set has 69 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 = utils.getOriginXY(interaction.interactable, interaction.element, interaction.prepared.name)
                    Severity: Major
                    Found in packages/modifiers/snap/pointer.ts - About 2 hrs to fix

                      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/actions/drop/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

                      Interaction has 23 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export class Interaction<T extends ActionName = any> {
                        // current interactable being interacted with
                        interactable: Interactable = null
                      
                        // the target element of the interactable
                      Severity: Minor
                      Found in packages/core/Interaction.ts - About 2 hrs to fix

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

                        function install (scope: Interact.Scope) {
                          const {
                            interact,
                            interactions,
                            defaults,
                        Severity: Major
                        Found in packages/auto-start/base.ts - About 2 hrs to fix

                          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
                            Severity
                            Category
                            Status
                            Source
                            Language