taye/interact.js

View on GitHub

Showing 197 of 211 total issues

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

        Function install has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function install (scope: Scope) {
          const signals = new Signals()
        
          const listeners = {} as any
        
        
        Severity: Minor
        Found in packages/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 (interactable: Interact.Interactable, element: Element, action, scope: Interact.Scope) {
          const options = interactable.options
          const maxActions = options[action.name].max
          const maxPerElement = options[action.name].maxPerElement
          const autoStartMax = scope.autoStart.maxInteractions
        Severity: Minor
        Found in packages/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) {
          const Element = domObjects.Element
          const navigator  = win.window.navigator
        
          // Does the browser support touch input?
        Severity: Minor
        Found in packages/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

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

          for (const [coordsSet, delta] of [[startCoords, startDelta], [curCoords, curDelta]]) {
            coordsSet.page.x   += delta.x
            coordsSet.page.y   += delta.y
            coordsSet.client.x += delta.x
            coordsSet.client.y += delta.y
        Severity: Major
        Found in packages/modifiers/base.ts and 1 other location - About 2 hrs to fix
        packages/modifiers/base.ts on lines 374..379

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

        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

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

          for (const [coordsSet, delta] of coordsAndDeltas as any) {
            coordsSet.page.x -= delta.x
            coordsSet.page.y -= delta.y
            coordsSet.client.x -= delta.x
            coordsSet.client.y -= delta.y
        Severity: Major
        Found in packages/modifiers/base.ts and 1 other location - About 2 hrs to fix
        packages/modifiers/base.ts on lines 344..349

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

        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 constructor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Interactable has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Interactable implements Partial<Eventable> {
            protected get _defaults (): Defaults {
              return {
                base: {},
                perAction: {},
          Severity: Minor
          Found in packages/core/Interactable.ts - About 2 hrs to fix

            InteractEvent has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class InteractEvent<
              T extends ActionName = any,
              P extends EventPhase = EventPhase._NONE,
            > extends BaseEvent<T> {
              target: Element
            Severity: Minor
            Found in packages/core/InteractEvent.ts - About 2 hrs to fix

              Function reflow has a Cognitive Complexity of 16 (exceeds 5 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 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/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 setAll has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function setAll (arg: Partial<Interact.SignalArg>) {
                const {
                  interaction,
                  modifiersState = interaction.modifiers,
                  prevCoords = modifiersState.result
              Severity: Major
              Found in packages/modifiers/base.ts - About 2 hrs to fix

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

                import { PerActionDefaults } from '@interactjs/core/defaultOptions'
                import Eventable from '@interactjs/core/Eventable'
                import Interaction from '@interactjs/core/Interaction'
                import { Scope } from '@interactjs/core/scope'
                import * as utils from '@interactjs/utils'
                Severity: Minor
                Found in packages/pointer-events/base.ts - About 2 hrs to fix

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

                  function install (scope: Scope) {
                    const {
                      pointerEvents,
                      actions,
                      Interactable,
                  Severity: Major
                  Found in packages/pointer-events/interactableTargets.ts - About 2 hrs to fix

                    Consider simplifying this complex logical expression.
                    Open

                      if (resizeOptions.square || resizeOptions.preserveAspectRatio) {
                        const linkedEdges = utils.extend({}, interaction.prepared.edges)
                    
                        linkedEdges.top    = linkedEdges.top    || (linkedEdges.left   && !linkedEdges.bottom)
                        linkedEdges.left   = linkedEdges.left   || (linkedEdges.top    && !linkedEdges.right)
                    Severity: Critical
                    Found in packages/actions/resize.ts - About 2 hrs to fix

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

                      function styleCursor (this: Interactable, newValue?: boolean) {
                        if (is.bool(newValue)) {
                          this.options.styleCursor = newValue
                      
                          return this
                      Severity: Major
                      Found in packages/auto-start/InteractableMethods.ts and 1 other location - About 2 hrs to fix
                      packages/auto-start/InteractableMethods.ts on lines 195..209

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

                      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

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

                      function actionChecker (this: Interactable, checker: any) {
                        if (is.func(checker)) {
                          this.options.actionChecker = checker
                      
                          return this
                      Severity: Major
                      Found in packages/auto-start/InteractableMethods.ts and 1 other location - About 2 hrs to fix
                      packages/auto-start/InteractableMethods.ts on lines 179..193

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

                      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 fire has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function fire<T extends string> (arg: {
                        interaction: Interaction,
                        pointer: Interact.PointerType,
                        event: Interact.PointerEventType,
                        eventTarget: Interact.EventTarget,
                      Severity: Minor
                      Found in packages/pointer-events/base.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language