taye/interact.js

View on GitHub

Showing 163 of 163 total issues

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

    Function setPerAction has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setPerAction(actionName: ActionName, options: OrBoolean<Options>) {
        const defaults = this._defaults
    
        // for all the default per-action options
        for (const optionName_ in options) {
    Severity: Minor
    Found in packages/@interactjs/core/Interactable.ts - About 1 hr to fix

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

      function set(arg) {
        const { interaction, state, coords } = arg
        const { options, offsets } = state
        const relative = {
          x: coords.x - offsets[0].x,
      Severity: Minor
      Found in packages/@interactjs/modifiers/snap/size.ts - About 1 hr to fix

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

          set(arg) {
            const { state, rect, coords } = arg
            const { linkedEdges } = state
            const initialCoords = extend({}, coords)
            const aspectMethod = state.equalDelta ? setEqualDelta : setRatio
        Severity: Minor
        Found in packages/@interactjs/modifiers/aspectRatio.ts - About 1 hr to fix

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

          module.exports = function transformImportsToAbsolute() {
            const fixImportSource = ({ node: { source } }, { opts, filename }) => {
              if (!source || (opts.ignore && opts.ignore(filename, source.value))) return
          
              const { moduleDirectory = getModuleDirectories() } = opts
          Severity: Minor
          Found in scripts/babel/absolute-imports.js - 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 transformImportsToAbsolute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function transformImportsToAbsolute() {
                const fixImportSource = ({ node: { source } }, { opts, filename }) => {
                  if (!source || (opts.ignore && opts.ignore(filename, source.value))) return
              
                  const { moduleDirectory = getModuleDirectories() } = opts
              Severity: Minor
              Found in scripts/babel/absolute-imports.js - 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 pointerExtend has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function pointerExtend<T>(dest: Partial<T & { __set?: Partial<T> }>, source: T) {
                dest.__set ||= {} as any
              
                for (const prop in source) {
                  // skip deprecated prefixed properties
              Severity: Minor
              Found in packages/@interactjs/utils/pointerExtend.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 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

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

                  new(target: Target, options?: any): Interactable {
                    options = extend(options || {}, {
                      actions: this.scope.actions,
                    })
                    const interactable = new this.scope.Interactable(target, options, this.scope.document, this.scope.events)
                Severity: Minor
                Found in packages/@interactjs/core/InteractableSet.ts - About 1 hr to fix

                  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 getActionInfo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function getActionInfo(
                      interaction: Interaction,
                      pointer: PointerType,
                      event: PointerEventType,
                      eventTarget: Node,
                    Severity: Minor
                    Found in packages/@interactjs/auto-start/base.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

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

                        function start(arg: ModifierArg<SnapState>) {
                          const { state, edges } = arg
                          const { options } = state
                        
                          if (!edges) {
                        Severity: Minor
                        Found in packages/@interactjs/modifiers/snap/size.ts - About 1 hr to fix

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

                            mouseOrPen({ pointerId, pointerType, eventType, scope }: SearchDetails) {
                              if (pointerType !== 'mouse' && pointerType !== 'pen') {
                                return null
                              }
                          
                          
                          Severity: Minor
                          Found in packages/@interactjs/core/interactionFinder.ts - About 1 hr to fix

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

                              interact.on = warnOnce(function on(type: string | EventTypes, listener: ListenersArg, options?: object) {
                                if (is.string(type) && type.search(' ') !== -1) {
                                  type = type.trim().split(/ +/)
                                }
                            
                            
                            Severity: Minor
                            Found in packages/@interactjs/core/InteractStatic.ts - About 1 hr to fix

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

                                reject() {
                                  const { dropState } = this._interaction
                              
                                  if (
                                    this.type !== 'dropactivate' &&
                              Severity: Minor
                              Found in packages/@interactjs/actions/drop/DropEvent.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

                                  Consider simplifying this complex logical expression.
                                  Open

                                    if (rect && !('left' in rect && 'top' in rect)) {
                                      rect = extend({}, rect)
                                  
                                      rect.left = rect.x || 0
                                      rect.top = rect.y || 0
                                  Severity: Major
                                  Found in packages/@interactjs/utils/rect.ts - About 1 hr to fix

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

                                    function dropCheckMethod(
                                      interactable: Interactable,
                                      dragEvent: InteractEvent,
                                      event: PointerEventType,
                                      draggable: Interactable,
                                    Severity: Minor
                                    Found in packages/@interactjs/actions/drop/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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language