divio/django-cms

View on GitHub
cms/static/cms/js/modules/jquery.ui.nestedsortable.js

Summary

Maintainability
F
1 wk
Test Coverage

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

        _mouseDrag: function(event) {
            var i, item, itemElement, intersection,
                o = this.options,
                scrolled = false;

Severity: Major
Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 7 hrs to fix

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

    /*
     * jQuery UI Nested Sortable
     * v 2.0 / 29 oct 2012
     * http://mjsarfatti.com/sandbox/nestedSortable
     *
    Severity: Minor
    Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 6 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                  else if (previousItem != null
                           && ! previousItem.hasClass(o.disableNestingClass)
                           &&
                              (previousItem.children(o.listType).length && previousItem.children(o.listType).is(':visible')
                               || ! previousItem.children(o.listType).length)
      Severity: Critical
      Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 2 hrs to fix

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

                toArray: function(options) {
        
                    var o = $.extend({}, this.options, options),
                        sDepth = o.startDepthCount || 0,
                        ret = [],
        Severity: Minor
        Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (this.floating && horizontalDirection) {
                          return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
                      } else {
                          return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && isOverTopHalf));
                      }
          Severity: Critical
          Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if (parentItem != null
                            && nextItem == null
                            && ! (o.protectRoot && parentItem[0].parentNode == this.element[0])
                            &&
                                (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth())
            Severity: Critical
            Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      } else if ( ! o.protectRoot) {
                                          this._rearrange(event, item);
                                      }
              Severity: Major
              Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (this.currentItem[0].parentNode != this.element[0]
                                                   && itemElement.parentNode == this.element[0]
                                            ) {
                
                                                if ( ! $(itemElement).children(o.listType).length) {
                Severity: Major
                Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js - About 45 mins to fix

                  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;
                                      }
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 6 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 105..109

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

                  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.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;
                                      }
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 6 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 99..103

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

                  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);
                                      }
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 6 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 113..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 160.

                  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);
                                      }
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 6 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 119..123

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

                  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() != $(o.listType)[0].nodeName.toLowerCase() || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
                                      if (previousItem[0].previousSibling) {
                                          previousItem = $(previousItem[0].previousSibling);
                                      } else {
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 5 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 272..281

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

                  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() != $(o.listType)[0].nodeName.toLowerCase() || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
                                      if (nextItem[0].nextSibling) {
                                          nextItem = $(nextItem[0].nextSibling);
                                      } else {
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 5 hrs to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 259..268

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

                  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

                              var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height*half), item.height),
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 1 hr to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 386..386

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

                  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

                                  isOverTopHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top - (item.height*half), item.height),
                  Severity: Major
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 1 hr to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 385..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 55.

                  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 (o.isTree && emptyList.length && emptyList.children().length && !emptyList.is(':visible')) {
                                  $(item).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.collapsedClass);
                              }
                  Severity: Minor
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 35 mins to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 549..553

                  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

                              } else if (o.isTree && emptyList.length && emptyList.children().length && emptyList.is(':visible')) {
                                  $(item).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.expandedClass);
                              } else if (o.isTree && emptyList.length && emptyList.children().length && !emptyList.is(':visible')) {
                                  $(item).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.collapsedClass);
                              }
                  Severity: Minor
                  Found in cms/static/cms/js/modules/jquery.ui.nestedsortable.js and 1 other location - About 35 mins to fix
                  cms/static/cms/js/modules/jquery.ui.nestedsortable.js on lines 551..553

                  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