File jquery.ui.sortable.js
has 729 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* jQuery UI Sortable 1.8.21
*
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
Function _mouseStart
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
_mouseStart: function(event, overrideHandle, noActivation) {
var o = this.options, self = this;
this.currentContainer = this;
Function _mouseDrag
has 55 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");
Function _clear
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
_clear: function(event, noPropagation) {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
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" && !isOverBottomHalf));
}
Consider simplifying this complex logical expression. Open
if(!(/^(document|window|parent)$/).test(o.containment)) {
var ce = $(o.containment)[0];
var co = $(o.containment).offset();
var over = ($(ce).css("overflow") != 'hidden');
Function _contactContainers
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
_contactContainers: function(event) {
// get innermost container that intersects with item
var innermostContainer = null, innermostIndex = null;
Function _generatePosition
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_generatePosition: function(event) {
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
// This is another very weird special case that only happens for relative elements:
Function _refreshItems
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_refreshItems: function(event) {
this.items = [];
this.containers = [this];
var items = this.items;
Function cancel
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
cancel: function() {
var self = this;
if(this.dragging) {
Function refreshPositions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
refreshPositions: function(fast) {
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
if(this.offsetParent && this.helper) {
this.offset.parent = this._getParentOffset();
Consider simplifying this complex logical expression. Open
if( this.options.tolerance == "pointer"
|| this.options.forcePointerForContainers
|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
) {
return isOverElement;
Avoid too many return
statements within this function. Open
return true;
Similar blocks of code found in 2 locations. Consider refactoring. Open
(function( $, undefined ) {
$.widget("ui.sortable", $.ui.mouse, {
widgetEventPrefix: "sort",
ready: false,
- Read upRead up
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 14317.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76