mambax7/alumni-26x

View on GitHub
media/jquery/jquery.tablesorter.widgets.js

Summary

Maintainability
F
1 wk
Test Coverage

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
Severity: Major
Found in media/jquery/jquery.tablesorter.widgets.js - About 3 days to fix

    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,
    Severity: Major
    Found in media/jquery/jquery.tablesorter.widgets.js - About 6 hrs to fix

      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;
              }
      Severity: Major
      Found in media/jquery/jquery.tablesorter.widgets.js - About 4 hrs to fix

        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();
                }
        Severity: Major
        Found in media/jquery/jquery.tablesorter.widgets.js - About 3 hrs to fix

          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,
          Severity: Major
          Found in media/jquery/jquery.tablesorter.widgets.js - About 3 hrs to fix

            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;
            Severity: Critical
            Found in media/jquery/jquery.tablesorter.widgets.js - About 3 hrs to fix

              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;
                          }
              Severity: Critical
              Found in media/jquery/jquery.tablesorter.widgets.js - About 2 hrs to fix

                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,
                Severity: Major
                Found in media/jquery/jquery.tablesorter.widgets.js - About 2 hrs to fix

                  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 + '">';
                  Severity: Minor
                  Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                    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,
                    Severity: Minor
                    Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                      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 = {},
                      Severity: Minor
                      Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                        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 : '';
                        Severity: Minor
                        Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                          Function addHeaderResizeEvent has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ts.addHeaderResizeEvent = function(table, disable, settings) {
                              var headers,
                                  defaults = {
                                      timer : 250
                                  },
                          Severity: Minor
                          Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                            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 };
                            Severity: Minor
                            Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                              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,
                              Severity: Minor
                              Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                Function exact has 10 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        exact: function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed, rowArray ) {
                                Severity: Major
                                Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                  Function wild has 10 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          wild : function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed, rowArray ) {
                                  Severity: Major
                                  Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                    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')
                                    Severity: Minor
                                    Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                      Function range has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                              range : function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed ) {
                                      Severity: Major
                                      Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                        Function operators has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                                operators: function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed ) {
                                        Severity: Major
                                        Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                          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),
                                          Severity: Minor
                                          Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                            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),
                                            Severity: Major
                                            Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                              Function notMatch has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                      notMatch: function( filter, iFilter, exact, iExact, cached, index, table, wo ) {
                                              Severity: Major
                                              Found in media/jquery/jquery.tablesorter.widgets.js - About 1 hr to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                        if (cell) {
                                                                            arry.push( $.trim( cell.textContent || cell.innerText || $(cell).text() ) );
                                                                        }
                                                Severity: Major
                                                Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                  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;
                                                  Severity: Major
                                                  Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                            if (filterMatched !== null) {
                                                                                showRow = filterMatched;
                                                                            } else {
                                                                                showRow = (iRowText + childRowText).indexOf(iAnyMatch) >= 0;
                                                                            }
                                                    Severity: Major
                                                    Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                      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] );
                                                                                  }
                                                      Severity: Major
                                                      Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                        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>';
                                                        Severity: Major
                                                        Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                          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) {
                                                          Severity: Major
                                                          Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                if (i === c.columns && $column.length) {
                                                                                    wo.filter_$anyMatch = $column;
                                                                                }
                                                            Severity: Major
                                                            Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                              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;
                                                              Severity: Major
                                                              Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                                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() || '';
                                                                Severity: Major
                                                                Found in media/jquery/jquery.tablesorter.widgets.js - About 45 mins to fix

                                                                  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);
                                                                  Severity: Major
                                                                  Found in media/jquery/jquery.tablesorter.widgets.js - About 40 mins to fix

                                                                    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 );
                                                                    Severity: Minor
                                                                    Found in media/jquery/jquery.tablesorter.widgets.js and 1 other location - About 50 mins to fix
                                                                    media/jquery/jquery.tablesorter.widgets.js on lines 448..450

                                                                    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

                                                                    Further Reading

                                                                    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 );
                                                                    Severity: Minor
                                                                    Found in media/jquery/jquery.tablesorter.widgets.js and 1 other location - About 50 mins to fix
                                                                    media/jquery/jquery.tablesorter.widgets.js on lines 506..508

                                                                    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

                                                                    Further Reading

                                                                    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);
                                                                    Severity: Minor
                                                                    Found in media/jquery/jquery.tablesorter.widgets.js and 1 other location - About 45 mins to fix
                                                                    media/jquery/jquery.tablesorter.widgets.js on lines 1110..1110

                                                                    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

                                                                    Further Reading

                                                                    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();
                                                                    Severity: Minor
                                                                    Found in media/jquery/jquery.tablesorter.widgets.js and 1 other location - About 45 mins to fix
                                                                    media/jquery/jquery.tablesorter.widgets.js on lines 621..621

                                                                    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

                                                                    Further Reading

                                                                    There are no issues that match your filters.

                                                                    Category
                                                                    Status