ivanzotov/constructor

View on GitHub
core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js

Summary

Maintainability
F
5 days
Test Coverage

Function _mouseDrag has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _mouseDrag: function(event) {

            //Compute the helpers position
            this.position = this._generatePosition(event);
            this.positionAbs = this._convertPositionTo("absolute");

    File jquery.ui.nestedSortable.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * jQuery UI Nested Sortable
     * v 1.3.5 / 21 jun 2012
     * http://mjsarfatti.com/code/nestedSortable
     *

      Function toArray has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              toArray: function(options) {
      
                  var o = $.extend({}, this.options, options),
                      sDepth = o.startDepthCount || 0,
                      ret = [],

        Consider simplifying this complex logical expression.
        Open

                    if (!o.isAllowed(this.currentItem, parentItem) ||
                        parentItem && parentItem.hasClass(o.disableNesting) ||
                        o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
                        this.placeholder.addClass(o.errorClass);
                        if (maxLevels < levels && maxLevels != 0) {
        Severity: Critical
        Found in core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (parentItem != null && nextItem == null &&
                          (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
                              !o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
                          parentItem.after(this.placeholder[0]);
                          this._clearEmpty(parentItem[0]);
          Severity: Major
          Found in core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js - About 40 mins to fix

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

                                if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
                                    this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
                                else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
                                    this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 64..67

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

            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((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
                                    this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
                                else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
                                    this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 69..72

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

            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(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
                                    scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                                else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
                                    scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 81..84

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

            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(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
                                    scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                                else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
                                    scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 76..79

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

            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 (previousItem != null) {
                            while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
                                if (previousItem[0].previousSibling) {
                                    previousItem = $(previousItem[0].previousSibling);
                                } else {
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 157..166

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

            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 (nextItem != null) {
                            while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
                                if (nextItem[0].nextSibling) {
                                    nextItem = $(nextItem[0].nextSibling);
                                } else {
            core/app/assets/javascripts/constructor_core/jquery.ui.nestedSortable.js on lines 144..153

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

            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