taye/interact.js

View on GitHub
packages/@interactjs/actions/resize/plugin.ts

Summary

Maintainability
F
3 days
Test Coverage

Function checkResizeEdge has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

function checkResizeEdge(
  name: string,
  value: any,
  page: Point,
  element: Node,
Severity: Minor
Found in packages/@interactjs/actions/resize/plugin.ts - About 6 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

File plugin.ts has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { Interactable } from '@interactjs/core/Interactable'
import type { EventPhase, InteractEvent } from '@interactjs/core/InteractEvent'
import type { Interaction } from '@interactjs/core/Interaction'
import type { PerActionDefaults } from '@interactjs/core/options'
import type { Scope, Plugin } from '@interactjs/core/scope'
Severity: Minor
Found in packages/@interactjs/actions/resize/plugin.ts - About 5 hrs to fix

    Function resizeChecker has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function resizeChecker(arg) {
      const { interaction, interactable, element, rect, buttons } = arg
    
      if (!rect) {
        return undefined
    Severity: Minor
    Found in packages/@interactjs/actions/resize/plugin.ts - About 3 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 resizeChecker has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function resizeChecker(arg) {
      const { interaction, interactable, element, rect, buttons } = arg
    
      if (!rect) {
        return undefined
    Severity: Major
    Found in packages/@interactjs/actions/resize/plugin.ts - About 2 hrs to fix

      Function checkResizeEdge has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function checkResizeEdge(
        name: string,
        value: any,
        page: Point,
        element: Node,
      Severity: Minor
      Found in packages/@interactjs/actions/resize/plugin.ts - About 1 hr to fix

        Function move has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function move({ iEvent, interaction }: { iEvent: InteractEvent<any, any>; interaction: Interaction }) {
          if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) return
        
          const resizeEvent = iEvent as ResizeEvent
          const resizeOptions = interaction.interactable.options.resize
        Severity: Minor
        Found in packages/@interactjs/actions/resize/plugin.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 initCursors has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function initCursors(browser: typeof import('@interactjs/utils/browser').default) {
          return browser.isIe9
            ? {
                x: 'e-resize',
                y: 's-resize',
        Severity: Minor
        Found in packages/@interactjs/actions/resize/plugin.ts - About 1 hr to fix

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

          function resizable(interactable: Interactable, options: OrBoolean<ResizableOptions> | boolean, scope: Scope) {
            if (is.object(options)) {
              interactable.options.resize.enabled = options.enabled !== false
              interactable.setPerAction('resize', options)
              interactable.setOnEvents('resize', options)
          Severity: Minor
          Found in packages/@interactjs/actions/resize/plugin.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 updateEventAxes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function updateEventAxes({
            iEvent,
            interaction,
          }: {
            iEvent: InteractEvent<any, any>
          Severity: Minor
          Found in packages/@interactjs/actions/resize/plugin.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 checkResizeEdge has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            name: string,
            value: any,
            page: Point,
            element: Node,
            interactableElement: Element,
          Severity: Major
          Found in packages/@interactjs/actions/resize/plugin.ts - About 50 mins to fix

            Consider simplifying this complex logical expression.
            Open

              if (is.object(resizeOptions.edges)) {
                const resizeEdges = {
                  left: false,
                  right: false,
                  top: false,
            Severity: Major
            Found in packages/@interactjs/actions/resize/plugin.ts - About 40 mins to fix

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

                getCursor({ edges, axis, name }: ActionProps) {
                  const cursors = resize.cursors
                  let result: string = null
              
                  if (axis) {
              Severity: Minor
              Found in packages/@interactjs/actions/resize/plugin.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 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 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

                    There are no issues that match your filters.

                    Category
                    Status