taye/interact.js

View on GitHub

Showing 156 of 156 total issues

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

function start (arg: ModifierArg<SnapState>) {
  const { interaction, interactable, element, rect, state, startOffset } = arg
  const { options } = state
  const origin = options.offsetWithOrigin
    ? getOrigin(arg)
Severity: Minor
Found in packages/@interactjs/modifiers/snap/pointer.ts - About 1 hr to fix

    Function set has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function set (arg) {
      const { interaction, state, coords } = arg
      const { options, offsets } = state
      const relative = {
        x: coords.x - offsets[0].x,
    Severity: Minor
    Found in packages/@interactjs/modifiers/snap/size.ts - About 1 hr to fix

      Function usePlugin has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        usePlugin (plugin: Plugin, options?: { [key: string]: any }) {
          if (!this.isInitialized) {
            return this
          }
      
      
      Severity: Minor
      Found in packages/@interactjs/core/scope.ts - About 1 hr to fix

        Function withinInteractionLimit has 28 lines of code (exceeds 25 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 1 hr to fix

          Function transformImportsToAbsolute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function transformImportsToAbsolute () {
            const resolve = require('resolve')
          
            const fixImportSource = ({ node: { source } }, { opts, filename }) => {
              if (!source || (opts.ignore && opts.ignore(filename, source.value))) { 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 pointerExtend has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function pointerExtend (dest, source) {
            for (const prop in source) {
              const prefixedPropREs = pointerExtend.prefixedPropREs
              let deprecated = false
          
          
          Severity: Minor
          Found in packages/@interactjs/utils/pointerExtend.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 ForOfStatement has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                ForOfStatement(path, state) {
                  const right = path.get('right')
                  if (
                    right.isArrayExpression() ||
                    right.isGenericType('Array') ||
          Severity: Minor
          Found in scripts/babelTransformForOfArray.js - About 1 hr to fix

            Function on has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              interact.on = function (type: string | Interact.EventTypes, listener: Interact.ListenersArg, options?: object) {
                if (is.string(type) && type.search(' ') !== -1) {
                  type = type.trim().split(/ +/)
                }
            
            
            Severity: Minor
            Found in packages/@interactjs/core/interactStatic.ts - About 1 hr to fix

              Function reject has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                reject () {
                  const { dropState } = this._interaction
              
                  if (
                    (this.type !== 'dropactivate') && (
              Severity: Minor
              Found in packages/@interactjs/actions/drop/DropEvent.ts - About 1 hr to fix

                Function setPerAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  setPerAction (actionName: Interact.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/@interactjs/core/Interactable.ts - About 1 hr to fix

                  Function off has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    interact.off = function (type: Interact.EventTypes, listener: any, options?: object) {
                      if (is.string(type) && type.search(' ') !== -1) {
                        type = type.trim().split(/ +/)
                      }
                  
                  
                  Severity: Minor
                  Found in packages/@interactjs/core/interactStatic.ts - About 1 hr to fix

                    Function getSwipe has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      getSwipe () {
                        const interaction = this._interaction
                    
                        if (interaction.prevEvent.speed < 600 ||
                            this.timeStamp - interaction.prevEvent.timeStamp > 150) {
                    Severity: Minor
                    Found in packages/@interactjs/core/InteractEvent.ts - About 1 hr to fix

                      Function new has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        new (target: Interact.Target, options?: any): Interactable {
                          options = extend(options || {}, {
                            actions: this.scope.actions,
                          })
                          const interactable = new this.scope.Interactable(target, options, this.scope.document, this.scope.events)
                      Severity: Minor
                      Found in packages/@interactjs/core/InteractableSet.ts - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                            if (prevCoords && prevRect) {
                              const rectChanged = newResult.rect.left !== prevRect.left ||
                                newResult.rect.right !== prevRect.right ||
                                newResult.rect.top !== prevRect.top ||
                                newResult.rect.bottom !== prevRect.bottom
                        Severity: Major
                        Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                            if (rect && !('left' in rect && 'top' in rect)) {
                              rect = extend({}, rect)
                          
                              rect.left   = rect.x || 0
                              rect.top    = rect.y || 0
                          Severity: Major
                          Found in packages/@interactjs/utils/rect.ts - About 1 hr to fix

                            Function beforeEnd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              beforeEnd (arg: Omit<Interact.DoAnyPhaseArg, 'iEvent'> & { state?: ModifierState }): void | false {
                                const { interaction, event } = arg
                                const states = this.states
                            
                                if (!states || !states.length) {
                            Severity: Minor
                            Found in packages/@interactjs/modifiers/Modification.ts - About 55 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 getTouchPair has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function getTouchPair (event) {
                              const touches = []
                            
                              // array of touches is supplied
                              if (is.array(event)) {
                            Severity: Minor
                            Found in packages/@interactjs/utils/pointerUtils.ts - About 55 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 updateEventAxes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function updateEventAxes ({ iEvent, interaction }: { iEvent: Interact.InteractEvent<any, any>, interaction: Interaction }) {
                              if (interaction.prepared.name !== 'resize' || !interaction.resizeAxes) { return }
                            
                              const options = interaction.interactable.options
                              const resizeEvent = iEvent as ResizeEvent
                            Severity: Minor
                            Found in packages/@interactjs/actions/resize/plugin.ts - About 55 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 resizable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function resizable (interactable: Interact.Interactable, options: Interact.OrBoolean<Interact.ResizableOptions> | boolean, scope: Scope) {
                              if (is.object(options)) {
                                interactable.options.resize.enabled = options.enabled !== false
                                interactable.setPerAction('resize', options)
                                interactable.setOnEvents('resize', options)
                            Severity: Minor
                            Found in packages/@interactjs/actions/resize/plugin.ts - About 55 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 dropCheckMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function dropCheckMethod (
                              interactable: Interact.Interactable,
                              dragEvent: InteractEvent,
                              event: Interact.PointerEventType,
                              draggable: Interact.Interactable,
                            Severity: Minor
                            Found in packages/@interactjs/actions/drop/plugin.ts - About 55 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