jgwhite/ember-sortable

View on GitHub
addon/src/modifiers/sortable-item.js

Summary

Maintainability
F
5 days
Test Coverage

File sortable-item.js has 511 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable ember/no-computed-properties-in-native-classes */
import Modifier from 'ember-modifier';
import { Promise, defer } from 'rsvp';
import { action, set } from '@ember/object';
import { DRAG_ACTIONS, ELEMENT_CLICK_ACTION, END_ACTIONS } from '../utils/constant';
Severity: Major
Found in addon/src/modifiers/sortable-item.js - About 1 day to fix

    SortableItemModifier has 50 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class SortableItemModifier extends Modifier {
      className = 'sortable-item';
    
      @service('ember-sortable-internal-state') sortableService;
    
    
    Severity: Minor
    Found in addon/src/modifiers/sortable-item.js - About 7 hrs to fix

      Function _scrollOnEdges has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _scrollOnEdges(drag) {
          let groupDirection = this.direction;
          let element = this.element;
          let scrollContainer = new ScrollContainer(scrollParent(element));
          let itemContainer = {
      Severity: Major
      Found in addon/src/modifiers/sortable-item.js - About 2 hrs to fix

        Function _scrollOnEdges has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          _scrollOnEdges(drag) {
            let groupDirection = this.direction;
            let element = this.element;
            let scrollContainer = new ScrollContainer(scrollParent(element));
            let itemContainer = {
        Severity: Minor
        Found in addon/src/modifiers/sortable-item.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

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

          _makeDragHandler(startEvent) {
            const groupDirection = this.direction;
            let dragOrigin;
            let elementOrigin;
            let scrollOrigin;
        Severity: Minor
        Found in addon/src/modifiers/sortable-item.js - About 1 hr to fix

          Function _waitForTransition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _waitForTransition() {
              let waiterToken;
          
              if (DEBUG) {
                waiterToken = sortableItemWaiter.beginAsync();
          Severity: Minor
          Found in addon/src/modifiers/sortable-item.js - About 25 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

              if (groupDirection === 'x') {
                dragOrigin = getX(startEvent);
                elementOrigin = this.x;
                scrollOrigin = parentElement.getBoundingClientRect().left;
          
          
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 5 hrs to fix
          addon/src/modifiers/sortable-item.js on lines 534..547

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

          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 (groupDirection === 'y') {
                dragOrigin = getY(startEvent);
                elementOrigin = this.y;
                scrollOrigin = parentElement.getBoundingClientRect().top;
          
          
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 5 hrs to fix
          addon/src/modifiers/sortable-item.js on lines 519..532

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

          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

            removeEventListener() {
              this.element.removeEventListener('keydown', this.keyDown);
              this.element.removeEventListener('mousedown', this.mouseDown);
              this.element.removeEventListener('touchstart', this.touchStart);
              this.listenersRegistered = false;
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 2 hrs to fix
          addon/src/modifiers/sortable-item.js on lines 801..806

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

          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

            addEventListener() {
              this.element.addEventListener('keydown', this.keyDown);
              this.element.addEventListener('mousedown', this.mouseDown);
              this.element.addEventListener('touchstart', this.touchStart);
              this.listenersRegistered = true;
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 2 hrs to fix
          addon/src/modifiers/sortable-item.js on lines 808..813

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

          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

            set isDragging(value) {
              if (value) {
                this.element.classList.add('is-dragging');
              } else {
                this.element.classList.remove('is-dragging');
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 1 hr to fix
          addon/src/modifiers/sortable-item.js on lines 215..222

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

          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

            set isDropping(value) {
              if (value) {
                this.element.classList.add('is-dropping');
              } else {
                this.element.classList.remove('is-dropping');
          Severity: Major
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 1 hr to fix
          addon/src/modifiers/sortable-item.js on lines 174..181

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

          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

            freeze() {
              let el = this.element;
              if (!el) {
                return;
              }
          Severity: Minor
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 40 mins to fix
          addon/src/modifiers/sortable-item.js on lines 316..323

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

          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

            thaw() {
              let el = this.element;
              if (!el) {
                return;
              }
          Severity: Minor
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 40 mins to fix
          addon/src/modifiers/sortable-item.js on lines 289..296

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

          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

            set x(value) {
              if (value !== this._x) {
                this._x = value;
                this._scheduleApplyPosition();
              }
          Severity: Minor
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 35 mins to fix
          addon/src/modifiers/sortable-item.js on lines 760..765

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

          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

            set y(value) {
              if (value !== this._y) {
                this._y = value;
                this._scheduleApplyPosition();
              }
          Severity: Minor
          Found in addon/src/modifiers/sortable-item.js and 1 other location - About 35 mins to fix
          addon/src/modifiers/sortable-item.js on lines 740..745

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

          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

          There are no issues that match your filters.

          Category
          Status