shipshapecode/tether

View on GitHub

Showing 67 of 67 total issues

File tether.js has 666 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import '../css/tether.scss';
import '../css/tether-theme-arrows.scss';
import '../css/tether-theme-arrows-dark.scss';
import '../css/tether-theme-basic.scss';
import Abutment from './abutment';
Severity: Major
Found in src/js/tether.js - About 1 day to fix

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

      move(pos) {
        if (isUndefined(this.element.parentNode)) {
          return;
        }
    
    
    Severity: Minor
    Found in src/js/tether.js - About 1 day 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

    function _calculateOOBAndPinnedLeft(left, bounds, width, pin, pinned, oob) {
      if (left < bounds[0]) {
        if (pin.indexOf('left') >= 0) {
          left = bounds[0];
          pinned.push('left');
    Severity: Major
    Found in src/js/constraint.js and 1 other location - About 6 hrs to fix
    src/js/constraint.js on lines 131..151

    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 171.

    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

    function _calculateOOBAndPinnedTop(top, bounds, height, pin, pinned, oob) {
      if (top < bounds[1]) {
        if (pin.indexOf('top') >= 0) {
          top = bounds[1];
          pinned.push('top');
    Severity: Major
    Found in src/js/constraint.js and 1 other location - About 6 hrs to fix
    src/js/constraint.js on lines 97..117

    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 171.

    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 move has 149 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

      move(pos) {
        if (isUndefined(this.element.parentNode)) {
          return;
        }
    
    
    Severity: Major
    Found in src/js/tether.js - About 5 hrs to fix

      Function position has 148 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

        position(flushChanges = true) {
          // flushChanges commits the changes immediately, leave true unless you are positioning multiple
          // tethers (in which case call Tether.Utils.flush yourself when you're done)
      
          if (!this.enabled) {
      Severity: Major
      Found in src/js/tether.js - About 5 hrs to fix

        Function position has 133 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

          position({ top, left, targetAttachment }) {
            if (!this.options.constraints) {
              return true;
            }
        
        
        Severity: Major
        Found in src/js/constraint.js - About 5 hrs to fix

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

                if (changeAttachY === 'element' || changeAttachY === 'both') {
                  if (top < bounds[1] && eAttachment.top === 'bottom') {
                    top += height;
                    eAttachment.top = 'top';
                  }
          Severity: Major
          Found in src/js/constraint.js and 2 other locations - About 3 hrs to fix
          src/js/constraint.js on lines 343..353
          src/js/constraint.js on lines 359..369

          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 113.

          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 3 locations. Consider refactoring.
          Open

                if (changeAttachY === 'target' || changeAttachY === 'both') {
                  if (top < bounds[1] && tAttachment.top === 'top') {
                    top += targetHeight;
                    tAttachment.top = 'bottom';
                  }
          Severity: Major
          Found in src/js/constraint.js and 2 other locations - About 3 hrs to fix
          src/js/constraint.js on lines 359..369
          src/js/constraint.js on lines 375..385

          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 113.

          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 3 locations. Consider refactoring.
          Open

                if (changeAttachX === 'target' || changeAttachX === 'both') {
                  if (left < bounds[0] && tAttachment.left === 'left') {
                    left += targetWidth;
                    tAttachment.left = 'right';
                  }
          Severity: Major
          Found in src/js/constraint.js and 2 other locations - About 3 hrs to fix
          src/js/constraint.js on lines 343..353
          src/js/constraint.js on lines 375..385

          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 113.

          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

            } else if (tAttachment.left === 'center') {
              if (left + width > bounds[2] && eAttachment.left === 'left') {
                left -= width;
                eAttachment.left = 'right';
          
          
          Severity: Major
          Found in src/js/constraint.js and 1 other location - About 3 hrs to fix
          src/js/constraint.js on lines 254..263

          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 110.

          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 (tAttachment.top === 'middle') {
              if (top + height > bounds[3] && eAttachment.top === 'top') {
                top -= height;
                eAttachment.top = 'bottom';
          
          
          Severity: Major
          Found in src/js/constraint.js and 1 other location - About 3 hrs to fix
          src/js/constraint.js on lines 196..205

          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 110.

          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

          File constraint.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { getClass, updateClasses } from './utils/classes';
          import { defer } from './utils/deferred';
          import { extend } from './utils/general';
          import { getBounds } from './utils/bounds';
          import { isString, isUndefined } from './utils/type-check';
          Severity: Minor
          Found in src/js/constraint.js - About 3 hrs to fix

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

              } else if (left + width > bounds[2] && tAttachment.left === 'right') {
                if (eAttachment.left === 'left') {
                  left -= targetWidth;
                  tAttachment.left = 'left';
            
            
            Severity: Major
            Found in src/js/constraint.js and 1 other location - About 3 hrs to fix
            src/js/constraint.js on lines 164..205

            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 107.

            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 (left < bounds[0] && tAttachment.left === 'left') {
                if (eAttachment.left === 'right') {
                  left += targetWidth;
                  tAttachment.left = 'right';
            
            
            Severity: Major
            Found in src/js/constraint.js and 1 other location - About 3 hrs to fix
            src/js/constraint.js on lines 180..205

            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 107.

            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 position has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              position(flushChanges = true) {
                // flushChanges commits the changes immediately, leave true unless you are positioning multiple
                // tethers (in which case call Tether.Utils.flush yourself when you're done)
            
                if (!this.enabled) {
            Severity: Minor
            Found in src/js/tether.js - About 2 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

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

                if (left <= targetPos.right && right >= targetPos.left) {
                  ['top', 'bottom'].forEach((side) => {
                    const targetPosSide = targetPos[side];
                    if (targetPosSide === top || targetPosSide === bottom) {
                      abutted.push(side);
            Severity: Major
            Found in src/js/abutment.js and 1 other location - About 2 hrs to fix
            src/js/abutment.js on lines 17..24

            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 88.

            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 (top <= targetPos.bottom && bottom >= targetPos.top) {
                  ['left', 'right'].forEach((side) => {
                    const targetPosSide = targetPos[side];
                    if (targetPosSide === left || targetPosSide === right) {
                      abutted.push(side);
            Severity: Major
            Found in src/js/abutment.js and 1 other location - About 2 hrs to fix
            src/js/abutment.js on lines 26..33

            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 88.

            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 updateAttachClasses has 58 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

              updateAttachClasses(elementAttach, targetAttach) {
                elementAttach = elementAttach || this.attachment;
                targetAttach = targetAttach || this.targetAttachment;
                const sides = ['left', 'top', 'bottom', 'right', 'middle', 'center'];
                const { classes, classPrefix } = this.options;
            Severity: Major
            Found in src/js/tether.js - About 2 hrs to fix

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

                      if (left + width > bounds[2]) {
                        if (eAttachment.left === 'left') {
                          left -= width;
                          eAttachment.left = 'right';
                        } else if (eAttachment.left === 'center') {
              Severity: Major
              Found in src/js/constraint.js and 1 other location - About 2 hrs to fix
              src/js/constraint.js on lines 388..396

              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 75.

              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

              Severity
              Category
              Status
              Source
              Language