taye/interact.js

View on GitHub

Showing 130 of 144 total issues

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

function set (arg: Interact.SignalArg) {
  const { interaction, coords, state } = arg
  const { options, offsets } = state

  const origin = utils.getOriginXY(interaction.interactable, interaction.element, interaction.prepared.name)
Severity: Minor
Found in packages/modifiers/snap/pointer.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 index.ts has 374 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

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

    export function indexOfDeepestElement (elements) {
      let deepestZoneParents = []
      let dropzoneParents = []
      let dropzone
      let deepestZone = elements[0]
    Severity: Minor
    Found in packages/utils/domUtils.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 base.ts has 363 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 4 hrs to fix

      File Interaction.ts has 328 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 3 hrs to fix

        Function exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function({ template, types: t }) {
          const pushComputedProps = pushComputedPropsLoose
        
          const buildForOfArray = template(`
            for (var KEY = 0; KEY < ARR.length; KEY++) BODY;
        Severity: Minor
        Found in babel-transform-for-of-array.js - 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 81 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 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 indexOfDeepestElement has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function indexOfDeepestElement (elements) {
                let deepestZoneParents = []
                let dropzoneParents = []
                let dropzone
                let deepestZone = elements[0]
              Severity: Major
              Found in packages/utils/domUtils.ts - About 2 hrs to fix

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

                function set (arg: Interact.SignalArg) {
                  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

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

                      Interaction has 22 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

                        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 361..366

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

                        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

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

                          for (const [coordsSet, delta] of [[coords.start, startDelta], [coords.cur, 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 336..341

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language