shipshapecode/tether

View on GitHub

Showing 67 of 67 total issues

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

        if (left < bounds[0]) {
          if (eAttachment.left === 'right') {
            left += width;
            eAttachment.left = 'left';
          } 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 398..406

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

Function setOptions has 54 lines of code (exceeds 30 allowed). Consider refactoring.
Open

  setOptions(options, pos = true) {
    const defaults = {
      offset: '0 0',
      targetOffset: '0 0',
      targetAttachment: 'auto auto',
Severity: Major
Found in src/js/tether.js - About 1 hr to fix

    Function getScrollParents has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getScrollParents(el) {
      // In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
      // https://bugzilla.mozilla.org/show_bug.cgi?id=548397
      const computedStyle = getComputedStyle(el) || {};
      const { position } = computedStyle;
    Severity: Minor
    Found in src/js/utils/parents.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 _flipXTogether has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function _flipXTogether(tAttachment, eAttachment, bounds, width, targetWidth, left) {
      if (left < bounds[0] && tAttachment.left === 'left') {
        if (eAttachment.left === 'right') {
          left += targetWidth;
          tAttachment.left = 'right';
    Severity: Minor
    Found in src/js/constraint.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

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

      if (isString(offset.left) && offset.left.indexOf('%') !== -1) {
        offset.left = parseFloat(offset.left) / 100 * size.width;
      }
    Severity: Major
    Found in src/js/utils/offset.js and 1 other location - About 1 hr to fix
    src/js/utils/offset.js on lines 74..76

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

    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 (isString(offset.top) && offset.top.indexOf('%') !== -1) {
        offset.top = parseFloat(offset.top) / 100 * size.height;
      }
    Severity: Major
    Found in src/js/utils/offset.js and 1 other location - About 1 hr to fix
    src/js/utils/offset.js on lines 71..73

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

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

    export function getScrollHandleBounds(body, target) {
      let bounds;
      // We have to do the check for the scrollTop and if target === document.body here and set to variables
      // because we may reset target below.
      const targetScrollTop = target.scrollTop;
    Severity: Minor
    Found in src/js/utils/bounds.js - About 1 hr to fix

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

      export function addClass(el, name) {
        name.split(' ').forEach((cls) => {
          if (cls.trim()) {
            el.classList.add(cls);
          }
      Severity: Major
      Found in src/js/utils/classes.js and 1 other location - About 1 hr to fix
      src/js/utils/classes.js on lines 30..36

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

      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

      export function removeClass(el, name) {
        name.split(' ').forEach((cls) => {
          if (cls.trim()) {
            el.classList.remove(cls);
          }
      Severity: Major
      Found in src/js/utils/classes.js and 1 other location - About 1 hr to fix
      src/js/utils/classes.js on lines 3..9

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

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

        position({ top, left }) {
          const { height, width } = this.cache('element-bounds', () => {
            return getBounds(this.element);
          });
      
      
      Severity: Minor
      Found in src/js/abutment.js - About 1 hr to fix

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

        function _flipYTogether(tAttachment, eAttachment, bounds, height, targetHeight, top) {
          if (tAttachment.top === 'top') {
            if (eAttachment.top === 'bottom' && top < bounds[1]) {
              top += targetHeight;
              tAttachment.top = 'bottom';
        Severity: Minor
        Found in src/js/constraint.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

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

                if (_same.top) {
                  css.top = `${_pos.top}px`;
                } else {
                  css.bottom = `${_pos.bottom}px`;
                }
        Severity: Major
        Found in src/js/tether.js and 1 other location - About 1 hr to fix
        src/js/tether.js on lines 642..646

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

        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 (_same.left) {
                  css.left = `${_pos.left}px`;
                } else {
                  css.right = `${_pos.right}px`;
                }
        Severity: Major
        Found in src/js/tether.js and 1 other location - About 1 hr to fix
        src/js/tether.js on lines 636..640

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

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

            const transcribe = (_same, _pos) => {
              const hasOptimizations = !isUndefined(this.options.optimizations);
              const gpu = hasOptimizations ? this.options.optimizations.gpu : null;
              if (gpu !== false) {
                let yPos, xPos;
        Severity: Minor
        Found in src/js/tether.js - About 1 hr to fix

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

                  if (_same.top) {
                    css.top = 0;
                    yPos = _pos.top;
                  } else {
                    css.bottom = 0;
          Severity: Major
          Found in src/js/tether.js and 1 other location - About 1 hr to fix
          src/js/tether.js on lines 615..621

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

          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 (_same.left) {
                    css.left = 0;
                    xPos = _pos.left;
                  } else {
                    css.right = 0;
          Severity: Major
          Found in src/js/tether.js and 1 other location - About 1 hr to fix
          src/js/tether.js on lines 607..613

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

          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 11 (exceeds 5 allowed). Consider refactoring.
          Open

            position({ manualOffset, manualTargetOffset }) {
              const offsets = {
                element: manualOffset,
                target: manualTargetOffset
              };
          Severity: Minor
          Found in src/js/tether.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 getBoundingRect has 34 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

          function getBoundingRect(body, tether, to) {
            // arg to is required
            if (!to) {
              return null;
            }
          Severity: Minor
          Found in src/js/constraint.js - About 1 hr to fix

            Function _flipYTogether has 34 lines of code (exceeds 30 allowed). Consider refactoring.
            Open

            function _flipYTogether(tAttachment, eAttachment, bounds, height, targetHeight, top) {
              if (tAttachment.top === 'top') {
                if (eAttachment.top === 'bottom' && top < bounds[1]) {
                  top += targetHeight;
                  tAttachment.top = 'bottom';
            Severity: Minor
            Found in src/js/constraint.js - About 1 hr to fix

              Function _flipXTogether has 34 lines of code (exceeds 30 allowed). Consider refactoring.
              Open

              function _flipXTogether(tAttachment, eAttachment, bounds, width, targetWidth, left) {
                if (left < bounds[0] && tAttachment.left === 'left') {
                  if (eAttachment.left === 'right') {
                    left += targetWidth;
                    tAttachment.left = 'right';
              Severity: Minor
              Found in src/js/constraint.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language