taye/interact.js

View on GitHub
packages/@interactjs/modifiers/Modification.ts

Summary

Maintainability
C
1 day
Test Coverage

File Modification.ts has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { EventPhase } from '@interactjs/core/InteractEvent'
import type { Interaction, DoAnyPhaseArg } from '@interactjs/core/Interaction'
import type { EdgeOptions, FullRect, Point, Rect } from '@interactjs/core/types'
import clone from '@interactjs/utils/clone'
import extend from '@interactjs/utils/extend'
Severity: Minor
Found in packages/@interactjs/modifiers/Modification.ts - About 4 hrs to fix

    Function setAll has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setAll(arg: MethodArg & Partial<ModifierArg>): ModificationResult {
        const { phase, preEnd, skipModifiers, rect: unmodifiedRect, edges: unmodifiedEdges } = arg
    
        arg.coords = extend({}, arg.pageCoords)
        arg.rect = extend({}, unmodifiedRect)
    Severity: Minor
    Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (
            // ignore disabled modifiers
            !options ||
            options.enabled === false ||
            // check if we require endOnly option to fire move before end
      Severity: Critical
      Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

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

          setAndApply(
            arg: Partial<DoAnyPhaseArg> & {
              phase: EventPhase
              preEnd?: boolean
              skipModifiers?: number
        Severity: Minor
        Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

          Function applyToInteraction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            applyToInteraction(arg: { phase: EventPhase; rect?: Rect }) {
              const { interaction } = this
              const { phase } = arg
              const curCoords = interaction.coords.cur
              const startCoords = interaction.coords.start
          Severity: Minor
          Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (prevCoords && prevRect) {
                  const rectChanged =
                    newResult.rect.left !== prevRect.left ||
                    newResult.rect.right !== prevRect.right ||
                    newResult.rect.top !== prevRect.top ||
            Severity: Major
            Found in packages/@interactjs/modifiers/Modification.ts - About 1 hr to fix

              Function beforeEnd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                beforeEnd(arg: Omit<DoAnyPhaseArg, 'iEvent'> & { state?: ModifierState }): void | false {
                  const { interaction, event } = arg
                  const states = this.states
              
                  if (!states || !states.length) {
              Severity: Minor
              Found in packages/@interactjs/modifiers/Modification.ts - About 55 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 setAll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                setAll(arg: MethodArg & Partial<ModifierArg>): ModificationResult {
                  const { phase, preEnd, skipModifiers, rect: unmodifiedRect, edges: unmodifiedEdges } = arg
              
                  arg.coords = extend({}, arg.pageCoords)
                  arg.rect = extend({}, unmodifiedRect)
              Severity: Minor
              Found in packages/@interactjs/modifiers/Modification.ts - About 45 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

              There are no issues that match your filters.

              Category
              Status