File jquery.tablesorter.widgets.js
has 1306 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*! tableSorter 2.16+ widgets - updated 4/27/2014 (v2.16.2)
*
* Column Styles
* Column Filters
* Column Resizing
Function findRows
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
findRows: function(table, filters, combinedFilters) {
if (table.config.lastCombinedFilter === combinedFilters) { return; }
var cached, len, $rows, cacheIndex, rowIndex, tbodyIndex, $tbody, $cells, columnIndex,
childRow, childRowText, exact, iExact, iFilter, lastSearch, matches, result,
notFiltered, searchFiltered, filterMatched, showRow, time,
Function format
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(table, c, wo) {
// filter widget doesn't initialize on an empty table. Fixes #449
if ( c.$table.hasClass('hasStickyHeaders') || ($.inArray('filter', c.widgets) >= 0 && !c.$table.hasClass('hasFilters')) ) {
return;
}
Function init
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function(table, c, wo) {
var options, string, $header, column, filters, time;
if (c.debug) {
time = new Date();
}
Function format
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(table, c, wo) {
if (c.$table.hasClass('hasResizable')) { return; }
c.$table.addClass('hasResizable');
ts.resizableReset(table, true); // set default widths
var $rows, $columns, $column, column,
Consider simplifying this complex logical expression. Open
if (combinedFilters === '' || wo.filter_serversideFiltering) {
$rows.removeClass(wo.filter_filteredRow).not('.' + c.cssChildRow).show();
} else {
// optimize searching only through already filtered rows - see #313
searchFiltered = true;
Consider simplifying this complex logical expression. Open
} else if ( (typeof wo.filter_liveSearch === 'number' && this.value.length < wo.filter_liveSearch && this.value !== '') ||
( event.type === 'keyup' && ( (event.which < 32 && event.which !== 8 && wo.filter_liveSearch === true && event.which !== 13) ||
( event.which >= 37 && event.which <= 40 ) || (event.which !== 13 && wo.filter_liveSearch === false) ) ) ) {
return;
}
Function format
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(table, c, wo) {
var i, time, classes, $header, $icon, $tfoot,
themesAll = ts.themes,
$table = c.$table,
$headers = c.$headers,
Function buildRow
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildRow: function(table, c, wo) {
var column, $header, buildSelect, disabled, name,
// c.columns defined in computeThIndexes()
columns = c.columns,
buildFilter = '<tr class="' + ts.css.filterRow + '">';
Function format
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(table, c, wo) {
var time, $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
$table = c.$table,
$tbodies = c.$tbodies,
sortList = c.sortList,
Function storage
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
ts.storage = function(table, key, value, options) {
table = $(table)[0];
var cookieIndex, cookies, date,
hasLocalStorage = false,
values = {},
Function getFilters
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
ts.getFilters = function(table, getRaw, setFilters, skipFirst) {
var i, $filters, $column,
filters = false,
c = table ? $(table)[0].config : '',
wo = c ? c.widgetOptions : '';
Function addHeaderResizeEvent
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
ts.addHeaderResizeEvent = function(table, disable, settings) {
var headers,
defaults = {
timer : 250
},
Function format
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(table, c, wo, init) {
var stored, time,
$table = c.$table,
saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
sortList = { "sortList" : c.sortList };
Function bindSearch
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
bindSearch: function(table, $el, internal) {
table = $(table)[0];
$el = $($el); // allow passing a selector string
if (!$el.length) { return; }
var c = table.config,
Function exact
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
exact: function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed, rowArray ) {
Function wild
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
wild : function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed, rowArray ) {
Function hideFilters
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
hideFilters: function(table, c) {
var $filterRow, $filterRow2, timer;
c.$table
.find('.' + ts.css.filterRow)
.addClass('hideme')
Function range
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
range : function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed ) {
Function operators
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
operators: function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed ) {
Function checkFilters
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkFilters: function(table, filter, skipFirst) {
var c = table.config,
wo = c.widgetOptions,
filterArray = $.isArray(filter),
filters = (filterArray) ? filter : ts.getFilters(table, true),
Consider simplifying this complex logical expression. Open
if ( /\s+(-|to)\s+/.test(iFilter) ) {
var result, tmp,
c = table.config,
query = iFilter.split(/(?: - | to )/), // make sure the dash is for a range and not indicating a negative number
range1 = ts.formatFloat(query[0].replace(ts.filter.regex.nondigit, ''), table),
Function notMatch
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
notMatch: function( filter, iFilter, exact, iExact, cached, index, table, wo ) {
Avoid deeply nested control flow statements. Open
if (cell) {
arry.push( $.trim( cell.textContent || cell.innerText || $(cell).text() ) );
}
Avoid deeply nested control flow statements. Open
if ($.inArray(type, anyMatchNotAllowedTypes) < 0) {
matches = typeFunction( anyMatch, iAnyMatch, rowText, iRowText, rowCache, columns, table, wo, parsed, rowArray );
if (matches !== null) {
filterMatched = matches;
return false;
Avoid deeply nested control flow statements. Open
if (filterMatched !== null) {
showRow = filterMatched;
} else {
showRow = (iRowText + childRowText).indexOf(iAnyMatch) >= 0;
}
Avoid deeply nested control flow statements. Open
for (indx = 1; indx < len; indx++) {
// secondary, tertiary, etc sort column classes
$cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
}
Avoid deeply nested control flow statements. Open
for (string in wo.filter_functions[column]) {
if (typeof string === 'string') {
options += options === '' ?
'<option value="">' + ($header.data('placeholder') || $header.attr('data-placeholder') || wo.filter_placeholder.select || '') + '</option>' : '';
options += '<option value="' + string + '">' + string + '</option>';
Avoid deeply nested control flow statements. Open
if (parsed[i]) {
txt = c.cache[tbodyIndex].normalized[cacheIndex][i];
} else {
txt = wo.filter_ignoreCase ? $(this).text().toLowerCase() : $(this).text();
if (c.sortLocaleCompare) {
Avoid deeply nested control flow statements. Open
if (i === c.columns && $column.length) {
wo.filter_$anyMatch = $column;
}
Avoid deeply nested control flow statements. Open
if (filters[columnIndex]) {
cached = c.cache[tbodyIndex].normalized[cacheIndex][columnIndex];
// check if column data should be from the cell or from parsed data
if (wo.filter_useParsedData || parsed[columnIndex]) {
exact = cached;
Avoid deeply nested control flow statements. Open
if ($.isArray(setFilters)) {
// skip first (latest input) to maintain cursor position while typing
(skipFirst ? $column.slice(1) : $column).val( setFilters[i] ).trigger('change.tsfilter');
} else {
filters[i] = $column.val() || '';
Consider simplifying this complex logical expression. Open
if ((wo.filter_$anyMatch && wo.filter_$anyMatch.length) || filters[c.columns]) {
anyMatch = wo.filter_$anyMatch && wo.filter_$anyMatch.val() || filters[c.columns] || '';
if (c.sortLocaleCompare) {
// replace accents
anyMatch = ts.replaceAccents(anyMatch);
Identical blocks of code found in 2 locations. Consider refactoring. Open
result = ( parsed[index] || c.parsers[index].type === 'numeric' ) && !isNaN(range1) && !isNaN(range2) ? cached :
isNaN(iExact) ? ts.formatFloat( iExact.replace(ts.filter.regex.nondigit, ''), table) :
ts.formatFloat( iExact, table );
- 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 51.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
cachedValue = ( parsed[index] || parser.type === 'numeric' ) && !isNaN(query) && cached ? cached :
isNaN(iExact) ? ts.formatFloat( iExact.replace(ts.filter.regex.nondigit, ''), table) :
ts.formatFloat( iExact, table );
- 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 51.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').append(options);
- 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 50.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
currentValue = c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').val();
- 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 50.
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