taye/interact.js

View on GitHub
packages/@interactjs/modifiers/snap/pointer.ts

Summary

Maintainability
C
1 day
Test Coverage

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

function set(arg: ModifierArg<SnapState>) {
  const { interaction, coords, state } = arg
  const { options, offsets } = state

  const origin = getOriginXY(interaction.interactable!, interaction.element!, interaction.prepared.name)
Severity: Minor
Found in packages/@interactjs/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

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

function set(arg: ModifierArg<SnapState>) {
  const { interaction, coords, state } = arg
  const { options, offsets } = state

  const origin = getOriginXY(interaction.interactable!, interaction.element!, interaction.prepared.name)
Severity: Major
Found in packages/@interactjs/modifiers/snap/pointer.ts - About 3 hrs to fix

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

      Consider simplifying this complex logical expression.
      Open

          if (
            !closest.target ||
            (inRange
              ? // is the closest target in range?
                closest.inRange && range !== Infinity
      Severity: Major
      Found in packages/@interactjs/modifiers/snap/pointer.ts - About 40 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status