taye/interact.js

View on GitHub

Showing 197 of 211 total issues

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 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 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 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 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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          utils.pointer.setCoords(interaction.coords.cur, [ {
            pageX  : pageUp.x   + state.sx,
            pageY  : pageUp.y   + state.sy,
            clientX: clientUp.x + state.sx,
            clientY: clientUp.y + state.sy,
        Severity: Major
        Found in packages/inertia/index.ts and 2 other locations - About 1 hr to fix
        packages/modifiers/base.ts on lines 398..403
        packages/modifiers/restrict/edges.ts on lines 34..39

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function scroll has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          scroll () {
            const { interaction } = autoScroll
            const { interactable, element } = interaction
            const options = interactable.options[autoScroll.interaction.prepared.name].autoScroll
            const container = getContainer(options.container, interactable, element)
        Severity: Minor
        Found in packages/auto-scroll/index.ts - About 1 hr to fix

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

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

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

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

                function install (scope: Scope) {
                  const {
                    actions,
                    Interactable,
                    interactions,
                Severity: Minor
                Found in packages/actions/gesture.ts - About 1 hr to fix

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

                    Function on has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function on (type: string | Interact.EventTypes, listener: Interact.ListenersArg, options?) {
                      if (utils.is.string(type) && type.search(' ') !== -1) {
                        type = type.trim().split(/ +/)
                      }
                    
                    
                    Severity: Minor
                    Found in packages/interact/interact.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 _onOff has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _onOff (method: 'on' | 'off', typeArg: Interact.EventTypes, listenerArg?: Interact.ListenersArg | null, options?: any) {
                        if (is.object(typeArg) && !is.array(typeArg)) {
                          options = listenerArg
                          listenerArg = null
                        }
                    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

                    Function scroll has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                      scroll () {
                        const { interaction } = autoScroll
                        const { interactable, element } = interaction
                        const options = interactable.options[autoScroll.interaction.prepared.name].autoScroll
                        const container = getContainer(options.container, interactable, element)
                    Severity: Minor
                    Found in packages/auto-scroll/index.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 pushComputedPropsLoose has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function pushComputedPropsLoose(path, file) {
                        const { node, scope, parent } = path
                        const { left } = node
                        let declar, id, intermediate
                    
                    
                    Severity: Minor
                    Found in babel-transform-for-of-array.js - About 1 hr to fix

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

                      function start (arg: Interact.SignalArg) {
                        const { interaction, interactable, element, rect, state, startOffset } = arg
                        const { options } = state
                        const offsets = []
                        const origin = options.offsetWithOrigin
                      Severity: Minor
                      Found in packages/modifiers/snap/pointer.ts - About 1 hr to fix

                        Function pointerMove has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          pointerMove (pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Node) {
                            if (!this.simulation && !(this.modifiers && this.modifiers.endPrevented)) {
                              this.updatePointer(pointer, event, eventTarget, false)
                              utils.pointer.setCoords(this.coords.cur, this.pointers.map((p) => p.pointer), this._now())
                            }
                        Severity: Minor
                        Found in packages/core/Interaction.ts - About 1 hr to fix

                          Function checker has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            checker (
                              _pointer: Interact.PointerType,
                              _event: Interact.PointerEventType,
                              interactable: Interact.Interactable,
                              element: Element,
                          Severity: Minor
                          Found in packages/actions/resize.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language