taye/interact.js

View on GitHub

Showing 142 of 156 total issues

Function checkAndPreventDefault has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function checkAndPreventDefault (interactable: Interact.Interactable, scope: Interact.Scope, event: Event) {
  const setting = interactable.options.preventDefault

  if (setting === 'never') { return }

Severity: Minor
Found in packages/core/interactablePreventDefault.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 getDropEvents has a Cognitive Complexity of 11 (exceeds 5 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

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 set has a Cognitive Complexity of 11 (exceeds 5 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/modifiers/snap/size.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 off has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function off (type, listener, 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 onInteractionMove has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  onInteractionMove ({ interaction, pointer }) {
    if (!(interaction.interacting() &&
          autoScroll.check(interaction.interactable, interaction.prepared.name))) {
      return
    }
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 unset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  unset () {
    events.remove(this.target as Node, 'all')

    if (is.string(this.target)) {
      // remove delegated events
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 startReflow has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function startReflow (scope: Scope, interactable: Interactable, element: Element, action: ActionProps, event: any) {
  const interaction = scope.interactions.new({ pointerType: 'reflow' })
  const signalArg = {
    interaction,
    event,
Severity: Minor
Found in packages/reflow/index.ts - About 1 hr to fix

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

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

      function install (scope: Interact.Scope) {
        const {
          autoStart,
          interactions,
          defaults,
      Severity: Minor
      Found in packages/auto-start/hold.ts - About 1 hr to fix

        Function normalize has 30 lines of code (exceeds 25 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

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

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

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

              Function set has 28 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/modifiers/snap/size.ts - About 1 hr to fix

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

                function install (scope: Scope) {
                  const {
                    interactions,
                  } = scope
                
                
                Severity: Minor
                Found in packages/modifiers/base.ts - About 1 hr to fix

                  Function start has a Cognitive Complexity of 10 (exceeds 5 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

                  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 _doPhase has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _doPhase (signalArg: Partial<Interact.SignalArg>) {
                      const { event, phase, preEnd, type } = signalArg
                      const beforeResult = this._signals.fire(`before-action-${phase}`, signalArg)
                  
                      if (beforeResult === false) {
                  Severity: Minor
                  Found in packages/core/Interaction.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 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/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 constructor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor () {
                      const scope = this as Scope
                  
                      ;(this as { Interactable: typeof InteractableBase }).Interactable = class Interactable extends InteractableBase implements InteractableBase {
                        get _defaults () { return scope.defaults }
                  Severity: Minor
                  Found in packages/core/scope.ts - About 1 hr to fix

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

                    function addDelegate (selector: string, context: Node, type: string, listener: Listener, optionalArg?: any) {
                      const options = getOptions(optionalArg)
                      if (!delegatedEvents[type]) {
                        delegatedEvents[type] = {
                          contexts : [],
                    Severity: Minor
                    Found in packages/utils/events.ts - About 1 hr to fix

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

                      module.exports = function combine (options) {
                        const headerContent = (options.replacer || (s => s))(options.headerContent ||
                          fs.readFileSync(options.headerFilename).toString())
                      
                        const { destDir, filename } = options
                      Severity: Minor
                      Found in scripts/bundle-header.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language