Showing 150 of 150 total issues
Function val
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
val: function( value ) {
var ret, hooks, isFunction,
elem = this[0];
if ( !arguments.length ) {
Function addCombinator
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addCombinator( matcher, combinator, base ) {
var dir = combinator.dir,
checkNonElements = base && dir === "parentNode",
doneName = done++;
Function extend
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
jQuery.extend = jQuery.fn.extend = function() {
var src, copyIsArray, copy, name, options, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
Function on
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
var type, origFn;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
Function stop
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
stop: function( type, clearQueue, gotoEnd ) {
var stopQueue = function( hooks ) {
var stop = hooks.stop;
delete hooks.stop;
stop( gotoEnd );
Function each
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
each: function( obj, callback, args ) {
var value,
i = 0,
length = obj.length,
isArray = isArraylike( obj );
Function showHide
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showHide( elements, show ) {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
Function when
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
when: function( subordinate /* , ..., subordinateN */ ) {
var i = 0,
resolveValues = core_slice.call( arguments ),
length = resolveValues.length,
Function clone
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var destElements, node, clone, i, srcElements,
inPage = jQuery.contains( elem.ownerDocument, elem );
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
Function access
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
length = elems.length,
bulk = key == null;
Function dispatch
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
dispatch: function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
Function style
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return;
}
Function data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
data: function( key, value ) {
var attrs, name,
elem = this[0],
i = 0,
data = null;
Function cleanData
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
cleanData: function( elems, /* internal */ acceptData ) {
var elem, type, id, data,
i = 0,
internalKey = jQuery.expando,
cache = jQuery.cache,
Consider simplifying this complex logical expression. Open
} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
diff = cache[1];
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
} else {
Function submitPurchase
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var submitPurchase = function (e) {
var $form = $('form#purchase');
if ($form.find('input:visible').length == 0) {
// this is the repeat flow, let it happen naturally
return;
Function completePurchase
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var completePurchase = function (response) {
var $form = $('form#purchase');
var sensitiveFields = ['number', 'cvv', 'expiration_month', 'expiration_year'];
hideProcessing();
switch (response.status_code) {
Function submitPurchase
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var submitPurchase = function (e) {
var $form = $('form#purchase');
if ($form.find('input:visible').length == 0) {
// this is the repeat flow, let it happen naturally
return;
Function completePurchase
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var completePurchase = function (response) {
var $form = $('form#purchase');
var sensitiveFields = ['number', 'cvv', 'expiration_month', 'expiration_year'];
hideProcessing();
switch (response.status_code) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).addClass( value.call( this, j, this.className ) );
});
}
- 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 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
- 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