File widget-columnSelector.js
has 447 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Widget: columnSelector (responsive table widget) - updated 9/27/2017 (v2.29.0) *//*
* Requires tablesorter v2.8+ and jQuery 1.7+
* by Justin Hallett & Rob Garrison
*/
/*jshint browser:true, jquery:true, unused:false */
Function setupSelector
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
setupSelector: function(c, wo) {
var index, name, $header, priority, col, colId, $el,
colSel = c.selector,
$container = colSel.$container,
useStorage = wo.columnSelector_saveColumns && ts.storage,
Function updateBreakpoints
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateBreakpoints: function(c, wo) {
var priority, col, column, breaks,
isHidden = [],
colSel = c.selector,
prefix = c.namespace + 'columnselector',
Function refreshColumns
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
refreshColumns: function( c, optName, optState ) {
var i, arry, $el, val,
colSel = c.selector,
isArry = $.isArray(optState || optName),
wo = c.widgetOptions;
Function attachTo
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
attachTo : function(table, elm) {
table = $(table)[0];
var colSel, wo, indx,
c = table.config,
$popup = $(elm);
Function setUpColspan
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
setUpColspan: function(c, wo) {
var index, span, nspace,
$window = $( window ),
hasSpans = false,
$cells = c.$table
Function setupBreakpoints
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
setupBreakpoints: function(c, wo) {
var colSel = c.selector;
// add responsive breakpoints
if (wo.columnSelector_mediaquery) {
Function adjustColspans
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
adjustColspans: function(c, wo) {
var index, cols, col, span, end, $cell,
colSel = c.selector,
filtered = wo.filter_filteredRow || 'filtered',
autoModeOn = wo.columnSelector_mediaquery && colSel.auto,
Function init
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function(table, c, wo) {
var $t, colSel;
// abort if no input is contained within the layout
$t = $(wo.columnSelector_layout);
Consider simplifying this complex logical expression. Open
if (typeof optName !== 'undefined' && optName !== null && colSel.$container.length) {
// pass "selectors" to update the all of the container contents
if ( optName === 'selectors' ) {
colSel.$container.empty();
tsColSel.setupSelector(c, wo);
Identical blocks of code found in 2 locations. Consider refactoring. Open
ts.window_resize = function() {
if ( ts.timer_resize ) {
clearTimeout( ts.timer_resize );
}
ts.timer_resize = setTimeout( function() {
- 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 73.
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