taye/interact.js

View on GitHub

Showing 197 of 211 total issues

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

      ForOfStatement(path, state) {
        const right = path.get('right')
        if (
          right.isArrayExpression() ||
          right.isGenericType('Array') ||
Severity: Minor
Found in babel-transform-for-of-array.js - About 1 hr to fix

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

    module.exports = function combine (options) {
      const headerContent = (options.replacer || (s => s))(options.headerContent ||
        fs.readFileSync(options.headerFilename).toString())
    
      const { destDir, filename } = options
    Severity: Minor
    Found in scripts/bundle-header.js - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if (inverted.left > inverted.right) {
              swap = inverted.left
      
              inverted.left = inverted.right
              inverted.right = swap
      Severity: Major
      Found in packages/actions/resize.ts and 1 other location - About 1 hr to fix
      packages/actions/resize.ts on lines 449..454

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            if (inverted.top > inverted.bottom) {
              swap = inverted.top
      
              inverted.top = inverted.bottom
              inverted.bottom = swap
      Severity: Major
      Found in packages/actions/resize.ts and 1 other location - About 1 hr to fix
      packages/actions/resize.ts on lines 455..460

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        getSwipe () {
          const interaction = this._interaction
      
          if (interaction.prevEvent.speed < 600 ||
              this.timeStamp - interaction.prevEvent.timeStamp > 150) {
      Severity: Minor
      Found in packages/core/InteractEvent.ts - About 1 hr to fix

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

        function off (type, listener, options) {
          if (utils.is.string(type) && type.search(' ') !== -1) {
            type = type.trim().split(/ +/)
          }
        
        
        Severity: Minor
        Found in packages/interact/interact.ts - About 1 hr to fix

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

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

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

            function createGrid (grid: (Interact.Rect | Interact.Point) & { range?: number, limits: Interact.Rect, offset: Interact.Point }) {
              const coordFields = [
                ['x', 'y'],
                ['left', 'top'],
                ['right', 'bottom'],
            Severity: Minor
            Found in packages/utils/snappers/grid.ts - About 1 hr to fix

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

                new (target: Interact.Target, options?: any): Interact.Interactable {
                  options = extend(options || {}, {
                    actions: this.scope.actions,
                  })
                  const interactable = new this.scope.Interactable(target, options, this.scope.document)
              Severity: Minor
              Found in packages/core/InteractableSet.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/utils/rect.ts - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

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

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

                      idle ({ pointerType, scope }: SearchDetails) {
                        for (const interaction of scope.interactions.list) {
                          // if there's already a pointer held down
                          if (interaction.pointers.length === 1) {
                            const target = interaction.interactable
                    Severity: Minor
                    Found in packages/core/interactionFinder.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 constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      constructor () {
                        const scope = this as Scope
                    
                        ; (this as { Interactable: typeof InteractableBase }).Interactable = class Interactable extends InteractableBase implements InteractableBase {
                          get _defaults () { return scope.defaults }
                    Severity: Minor
                    Found in packages/core/scope.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 dropCheckMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function dropCheckMethod (
                      interactable: Interact.Interactable,
                      dragEvent: InteractEvent,
                      event: Interact.PointerEventType,
                      draggable: Interact.Interactable,
                    Severity: Minor
                    Found in packages/actions/drop/index.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 getTouchPair has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      getTouchPair (event) {
                        const touches = []
                    
                        // array of touches is supplied
                        if (is.array(event)) {
                    Severity: Minor
                    Found in packages/utils/pointerUtils.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 pointerMove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      pointerMove (pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Node) {
                        if (!this.simulation && !(this.modifiers && this.modifiers.endPrevented)) {
                          this.updatePointer(pointer, event, eventTarget, false)
                          utils.pointer.setCoords(this.coords.cur, this.pointers.map((p) => p.pointer), this._now())
                        }
                    Severity: Minor
                    Found in packages/core/Interaction.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 resizable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function resizable (interactable: Interact.Interactable, options: Interact.OrBoolean<Interact.ResizableOptions> | boolean, scope: Scope) {
                      if (utils.is.object(options)) {
                        interactable.options.resize.enabled = options.enabled !== false
                        interactable.setPerAction('resize', options)
                        interactable.setOnEvents('resize', options)
                    Severity: Minor
                    Found in packages/actions/resize.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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          result[yField] = Math.max(limits.top, Math.min(limits.bottom, gridy * grid[yField] + offset.y))
                    Severity: Minor
                    Found in packages/utils/snappers/grid.ts and 1 other location - About 55 mins to fix
                    packages/utils/snappers/grid.ts on lines 27..27

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 53.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          result[xField] = Math.max(limits.left, Math.min(limits.right, gridx * grid[xField] + offset.x))
                    Severity: Minor
                    Found in packages/utils/snappers/grid.ts and 1 other location - About 55 mins to fix
                    packages/utils/snappers/grid.ts on lines 28..28

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 53.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Function getQuadraticCurvePoint has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      startX: number, startY: number, cpX: number, cpY: number, endX: number, endY: number, position: number) {
                    Severity: Major
                    Found in packages/utils/index.ts - About 50 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language