taye/interact.js

View on GitHub

Showing 163 of 163 total issues

Function main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function main() {
  const sources = fileArgs.length ? fileArgs : await getSources()

  console.log(`Linting ${sources.length} 'file${sources.length === 1 ? '' : 's'}...`)

Severity: Minor
Found in scripts/bin/lint.js - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

function set(arg: ModifierArg<RestrictSizeState>) {
  const { interaction, state, rect, edges } = arg
  const { options } = state

  if (!edges) {
Severity: Minor
Found in packages/@interactjs/modifiers/restrict/size.ts - About 35 mins 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 getPointerType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function getPointerType(pointer: { pointerType?: string; identifier?: number; type?: string }) {
  return is.string(pointer.pointerType)
    ? pointer.pointerType
    : is.number(pointer.pointerType)
      ? [undefined, undefined, 'touch', 'pen', 'mouse'][pointer.pointerType]!
Severity: Minor
Found in packages/@interactjs/utils/pointerUtils.ts - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

  set(options: OptionsArg) {
    const defaults = this._defaults

    if (!is.object(options)) {
      options = {}
Severity: Minor
Found in packages/@interactjs/core/Interactable.ts - About 35 mins 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

Avoid too many return statements within this function.
Open

  return is.element(value)
    ? // the value is an element to use as a resize handle
      value === element
    : // otherwise check if element matches value as selector
      dom.matchesUpTo(element, value, interactableElement)
Severity: Major
Found in packages/@interactjs/actions/resize/plugin.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return false
    Severity: Major
    Found in packages/@interactjs/core/Interactable.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return null
      Severity: Major
      Found in packages/@interactjs/core/interactionFinder.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return false
        Severity: Major
        Found in packages/@interactjs/actions/resize/plugin.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return page.y > (height >= 0 ? rect.bottom : rect.top) - margin
          Severity: Major
          Found in packages/@interactjs/actions/resize/plugin.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return true
            Severity: Major
            Found in packages/@interactjs/utils/shallowEqual.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return
              Severity: Major
              Found in packages/@interactjs/core/interactablePreventDefault.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return autoStartMax > 0
                Severity: Major
                Found in packages/@interactjs/auto-start/base.ts - About 30 mins to fix

                  Function init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function init(global: Window | typeof globalThis) {
                    request = global.requestAnimationFrame
                    cancel = global.cancelAnimationFrame
                  
                    if (!request) {
                  Severity: Minor
                  Found in packages/@interactjs/utils/raf.ts - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function set({ coords, edges, interaction, state }: ModifierArg<RestrictEdgesState>) {
                    const { offset, options } = state
                  
                    if (!edges) {
                      return
                  Severity: Minor
                  Found in packages/@interactjs/modifiers/restrict/edges.ts - About 25 mins 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 clone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function clone<T extends Object>(source: T): Partial<T> {
                    const dest = {} as Partial<T>
                  
                    for (const prop in source) {
                      const value = source[prop]
                  Severity: Minor
                  Found in packages/@interactjs/utils/clone.ts - About 25 mins 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 updatePointer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    updatePointer(pointer: PointerType, event: PointerEventType, eventTarget: Node, down?: boolean) {
                      const id = pointerUtils.getPointerId(pointer)
                      let pointerIndex = this.getPointerIndex(pointer)
                      let pointerInfo = this.pointers[pointerIndex]
                  
                  
                  Severity: Minor
                  Found in packages/@interactjs/core/Interaction.ts - About 25 mins 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 reject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    reject() {
                      const { dropState } = this._interaction
                  
                      if (
                        this.type !== 'dropactivate' &&
                  Severity: Minor
                  Found in packages/@interactjs/actions/drop/DropEvent.ts - About 25 mins 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 start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function start(arg: ModifierArg<SnapState>) {
                    const { interaction, interactable, element, rect, state, startOffset } = arg
                    const { options } = state
                    const origin = options.offsetWithOrigin ? getOrigin(arg) : { x: 0, y: 0 }
                  
                  
                  Severity: Minor
                  Found in packages/@interactjs/modifiers/snap/pointer.ts - About 25 mins 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 shouldDo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    shouldDo(options, preEnd?: boolean, phase?: string, requireEndOnly?: boolean) {
                      if (
                        // ignore disabled modifiers
                        !options ||
                        options.enabled === false ||
                  Severity: Minor
                  Found in packages/@interactjs/modifiers/Modification.ts - About 25 mins 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 draggable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const draggable: Interactable['draggable'] = function draggable(
                    this: Interactable,
                    options?: DraggableOptions | boolean,
                  ): any {
                    if (is.object(options)) {
                  Severity: Minor
                  Found in packages/@interactjs/actions/drag/plugin.ts - About 25 mins 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

                  Severity
                  Category
                  Status
                  Source
                  Language