taye/interact.js

View on GitHub
packages/@interactjs/core/events.ts

Summary

Maintainability
F
4 days
Test Coverage

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

function install(scope: Scope) {
  const targets: Array<{
    eventTarget: PartialEventTarget
    events: { [type: string]: ListenerEntry[] }
  }> = []
Severity: Minor
Found in packages/@interactjs/core/events.ts - About 2 days 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 204 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function install(scope: Scope) {
  const targets: Array<{
    eventTarget: PartialEventTarget
    events: { [type: string]: ListenerEntry[] }
  }> = []
Severity: Major
Found in packages/@interactjs/core/events.ts - About 1 day to fix

    File events.ts has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as arr from '@interactjs/utils/arr'
    import * as domUtils from '@interactjs/utils/domUtils'
    import is from '@interactjs/utils/is'
    import pExtend from '@interactjs/utils/pointerExtend'
    import * as pointerUtils from '@interactjs/utils/pointerUtils'
    Severity: Minor
    Found in packages/@interactjs/core/events.ts - About 2 hrs to fix

      Function remove has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function remove(
          eventTarget: PartialEventTarget,
          type: string,
          listener?: 'all' | ListenerEntry['func'],
          optionalArg?: boolean | EventOptions,
      Severity: Minor
      Found in packages/@interactjs/core/events.ts - About 1 hr to fix

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

          function removeDelegate(
            selector: string,
            context: Document | Element,
            type: string,
            listener?: ListenerEntry['func'],
        Severity: Minor
        Found in packages/@interactjs/core/events.ts - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                      if (optionsMatch(entry.options, options)) {
                        entry.func(fakeEvent)
                      }
          Severity: Major
          Found in packages/@interactjs/core/events.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (!listeners.length) {
                          delegates.splice(index, 1)
            
                          // remove delegate function from context
                          remove(context, type, delegateListener)
            Severity: Major
            Found in packages/@interactjs/core/events.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if (typeListeners.length === 0) {
                            delete target.events[type]
                            typeIsEmpty = true
                          }
              Severity: Major
              Found in packages/@interactjs/core/events.ts - About 45 mins to fix

                Function addDelegate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    selector: string,
                    context: Node,
                    type: string,
                    listener: ListenerEntry['func'],
                    optionalArg?: any,
                Severity: Minor
                Found in packages/@interactjs/core/events.ts - About 35 mins to fix

                  Function removeDelegate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      selector: string,
                      context: Document | Element,
                      type: string,
                      listener?: ListenerEntry['func'],
                      optionalArg?: any,
                  Severity: Minor
                  Found in packages/@interactjs/core/events.ts - About 35 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status