mambax7/alumni-26x

View on GitHub
media/jquery/tablesorter-master/js/widgets/widget-filter.js

Summary

Maintainability
F
1 wk
Test Coverage

File widget-filter.js has 1560 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! Widget: filter - updated 12/13/2017 (v2.29.1) *//*
 * Requires tablesorter v2.8+ and jQuery 1.7+
 * by Rob Garrison
 */
;( function ( $ ) {
Severity: Major
Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 4 days to fix

    Function findRows has 204 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            findRows: function( table, filters, currentFilters ) {
                if (
                    tsf.equalFilters(table.config, table.config.lastSearch, currentFilters) ||
                    !table.config.widgetOptions.filter_initialized
                ) {
    Severity: Major
    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 day to fix

      Function init has 177 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              init: function( table ) {
                  // filter language options
                  ts.language = $.extend( true, {}, {
                      to  : 'to',
                      or  : 'or',
      Severity: Major
      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 7 hrs to fix

        Function processRow has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                processRow: function( c, data, vars ) {
                    var result, filterMatched,
                        fxn, ffxn, txt,
                        wo = c.widgetOptions,
                        showRow = true,
        Severity: Major
        Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 4 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                              if ( searchFiltered ) {
                                  // cycle through all filters; include last ( columnIndex + 1 = match any column ). Fixes #669
                                  for ( indx = 0; indx < columnIndex + 1; indx++ ) {
                                      val = filters[indx] || '';
                                      // break out of loop if we've already determined not to search filtered rows
          Severity: Critical
          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 3 hrs to fix

            Function buildSelect has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    buildSelect: function( table, column, arry, updating, onlyAvail ) {
                        table = $( table )[0];
                        column = parseInt( column, 10 );
                        if ( !table.config.cache || $.isEmptyObject( table.config.cache ) ) {
                            return;
            Severity: Major
            Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

              Function buildRow has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      buildRow: function( table, c, wo ) {
                          var $filter, col, column, $header, makeSelect, disabled, name, ffxn, tmp,
                              // c.columns defined in computeThIndexes()
                              cellFilter = wo.filter_cellFilter,
                              columns = c.columns,
              Severity: Major
              Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

                Function bindSearch has 69 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 tmp,
                Severity: Major
                Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

                  Function getFilters has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      ts.getFilters = function( table, getRaw, setFilters, skipFirst ) {
                          var i, $filters, $column, cols,
                              filters = [],
                              c = table ? $( table )[0].config : '',
                              wo = c ? c.widgetOptions : '';
                  Severity: Major
                  Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

                    Function processOptions has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            processOptions: function( table, column, arry ) {
                                if ( !$.isArray( arry ) ) {
                                    return false;
                                }
                                table = $( table )[0];
                    Severity: Major
                    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

                      Consider simplifying this complex logical expression.
                      Open

                                      if ( table.config.widgetOptions.filter_initialized &&
                                          // immediate search if user presses enter
                                          ( event.which === tskeyCodes.enter ||
                                              // immediate search if a "search" or "blur" is triggered on the input
                                              ( eventType === 'search' || eventType === 'blur' ) ||
                      Severity: Critical
                      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 2 hrs to fix

                        Function checkFilters has 47 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/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                          Function findRange has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  findRange: function( c, val, ignoreRanges ) {
                                      // look for multiple columns '1-3,4-6,8' in data-column
                                      var temp, ranges, range, start, end, singles, i, indx, len,
                                          columns = [];
                                      if ( /^[0-9]+$/.test( val ) ) {
                          Severity: Minor
                          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                            Function getOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    getOptions: function( table, column, onlyAvail ) {
                                        table = $( table )[0];
                                        var rowIndex, tbodyIndex, len, row, cache, indx, child, childLen,
                                            c = table.config,
                                            wo = c.widgetOptions,
                            Severity: Minor
                            Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

                                              if ( ( tsfRegex.orTest.test( data.iFilter ) || tsfRegex.orSplit.test( data.filter ) ) &&
                                                  // this test for regex has potential to slow down the overall search
                                                  !tsfRegex.regex.test( data.filter ) ) {
                                                  var indx, filterMatched, query, regex,
                                                      // duplicate data but split filter
                              Severity: Critical
                              Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                                } else if ( this.value !== '' && (
                                                    // liveSearch can contain a min value length; ignore arrow and meta keys, but allow backspace
                                                    ( typeof liveSearch === 'number' && this.value.length < liveSearch ) ||
                                                    // let return & backspace continue on, but ignore arrows & non-valid characters
                                                    ( event.which !== tskeyCodes.enter && event.which !== tskeyCodes.backSpace &&
                                Severity: Critical
                                Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                  Function operators has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                              operators: function( c, data ) {
                                                  // ignore empty strings... because '' < 10 is true
                                                  if ( tsfRegex.operTest.test( data.iFilter ) && data.iExact !== '' ) {
                                                      var cachedValue, result, txt,
                                                          table = c.table,
                                  Severity: Minor
                                  Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                    Function range has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                                range : function( c, data ) {
                                                    if ( tsfRegex.toTest.test( data.iFilter ) ) {
                                                        var result, tmp, range1, range2,
                                                            table = c.table,
                                                            index = data.index,
                                    Severity: Minor
                                    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                      Function filterInitComplete has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                              filterInitComplete: function( c ) {
                                                  var indx, len,
                                                      wo = c.widgetOptions,
                                                      count = 0,
                                                      completed = function() {
                                      Severity: Minor
                                      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                        Function hideFilters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                                hideFilters: function( c, $table ) {
                                                    var timer;
                                                    ( $table || c.$table )
                                                        .find( '.' + tscss.filterRow )
                                                        .addClass( tscss.filterRowHide )
                                        Severity: Minor
                                        Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                          Function and has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                                      and : function( c, data, vars ) {
                                                          if ( tsfRegex.andTest.test( data.filter ) ) {
                                                              var indx, filterMatched, result, query, regex,
                                                                  // duplicate data but split filter
                                                                  data2 = $.extend( {}, data ),
                                          Severity: Minor
                                          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                            Function getOptionSource has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                    getOptionSource: function( table, column, onlyAvail ) {
                                                        table = $( table )[0];
                                                        var c = table.config,
                                                            wo = c.widgetOptions,
                                                            arry = false,
                                            Severity: Minor
                                            Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                              Consider simplifying this complex logical expression.
                                              Open

                                                          if ( validColumn && c.$headerIndexed[ column ].hasClass( 'filter-select-nosort' ) ) {
                                                              // unsorted select options
                                                              return arry;
                                                          } else {
                                                              len = arry.length;
                                              Severity: Major
                                              Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 1 hr to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                            if ( buildFilter && buildFilter.length === 0 ) {
                                                                                buildFilter = $filter.children( 'input' );
                                                                            }
                                                Severity: Major
                                                Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                              for ( indx = 0; indx < childRow.length; indx++ ) {
                                                                                  txt += ' ' + childRow[indx].join( ' ' ) || '';
                                                                              }
                                                  Severity: Major
                                                  Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                                if ( wo.filter_childByColumn ) {
                                                                                    if ( !wo.filter_childWithSibs ) {
                                                                                        // hide all child rows
                                                                                        childRow.addClass( wo.filter_filteredRow );
                                                                                        // if only showing resulting child row, only include parent
                                                    Severity: Major
                                                    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                              if ( txt.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
                                                                                  t = txt.split( wo.filter_selectSourceSeparator );
                                                                                  val = t[0];
                                                                                  txt = t[1];
                                                                              }
                                                      Severity: Major
                                                      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.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/tablesorter-master/js/widgets/widget-filter.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
                                                                                      if ( skipFirst && $column.length > 1 ) {
                                                                                          $column = $column.slice( 1 );
                                                                                      }
                                                          Severity: Major
                                                          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                        if ( buildFilter && ( buildFilter.parent().length === 0 ||
                                                                                            ( buildFilter.parent().length && buildFilter.parent()[0] !== $filter[0] ) ) ) {
                                                                                            $filter.append( buildFilter );
                                                                                        }
                                                            Severity: Major
                                                            Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                                          if ( injected ) {
                                                                                              data.anyMatchFilter = query.join( ' && ' );
                                                                                          }
                                                              Severity: Major
                                                              Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                                            if ( fxn === true ) {
                                                                                                // default selector uses exact match unless 'filter-match' class is found
                                                                                                result = data.isMatch ?
                                                                                                    // data.iExact may be a number
                                                                                                    ( '' + data.iExact ).search( data.iFilter ) >= 0 :
                                                                Severity: Major
                                                                Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                                              if ( !searchFiltered ) { indx = columnIndex; }
                                                                  Severity: Major
                                                                  Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                                                if ( option.hasOwnProperty( val ) && val !== 'text' ) {
                                                                                                    options += ' ' + val + '="' + option[ val ] + '"';
                                                                                                }
                                                                    Severity: Major
                                                                    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                                  for ( string in fxn ) {
                                                                                                      if ( typeof string === 'string' ) {
                                                                                                          options += options === '' ?
                                                                                                              '<option value="">' +
                                                                                                                  ( $header.data( 'placeholder' ) ||
                                                                      Severity: Major
                                                                      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                        Avoid deeply nested control flow statements.
                                                                        Open

                                                                                                    if ( fxn ) {
                                                                                                        // updating so the extra options are appended
                                                                                                        tsf.buildSelect( c.table, column, '', true, $header.hasClass( wo.filter_onlyAvail ) );
                                                                                                    }
                                                                        Severity: Major
                                                                        Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                          Avoid deeply nested control flow statements.
                                                                          Open

                                                                                                      for ( indx = 0; indx < childLen; indx++ ) {
                                                                                                          arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ];
                                                                                                      }
                                                                          Severity: Major
                                                                          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                            Avoid deeply nested control flow statements.
                                                                            Open

                                                                                                        for ( indx = 0; indx < query.length; indx++ ) {
                                                                                                            res = query[ indx ].split( ':' );
                                                                                                            if ( res.length > 1 ) {
                                                                                                                // make the column a one-based index ( non-developers start counting from one :P )
                                                                                                                if ( isNaN( res[0] ) ) {
                                                                            Severity: Major
                                                                            Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                              Avoid deeply nested control flow statements.
                                                                              Open

                                                                                                          for ( indx = 1; indx < childLen; indx++ ) {
                                                                                                              child =  cache.normalized[ rowIndex ][ c.columns ].$row.eq( indx ).children().eq( column );
                                                                                                              arry[ arry.length ] = '' + ts.getElementText( c, child, column );
                                                                                                          }
                                                                              Severity: Major
                                                                              Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 45 mins to fix

                                                                                Consider simplifying this complex logical expression.
                                                                                Open

                                                                                        if ( ( getRaw !== true && wo && !wo.filter_columnFilters ) ||
                                                                                            // setFilters called, but last search is exactly the same as the current
                                                                                            // fixes issue #733 & #903 where calling update causes the input values to reset
                                                                                            ( $.isArray(setFilters) && tsf.equalFilters(c, setFilters, c.lastSearch) )
                                                                                        ) {
                                                                                Severity: Major
                                                                                Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 40 mins to fix

                                                                                  Consider simplifying this complex logical expression.
                                                                                  Open

                                                                                                      if ( ( wo.filter_$anyMatch && wo.filter_$anyMatch.length ) ||
                                                                                                          typeof filters[c.columns] !== 'undefined' ) {
                                                                                                          data.anyMatchFlag = true;
                                                                                                          data.anyMatchFilter = '' + (
                                                                                                              filters[ c.columns ] ||
                                                                                  Severity: Major
                                                                                  Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 40 mins to fix

                                                                                    Consider simplifying this complex logical expression.
                                                                                    Open

                                                                                                    if ( tsfRegex.toTest.test( data.iFilter ) ) {
                                                                                                        var result, tmp, range1, range2,
                                                                                                            table = c.table,
                                                                                                            index = data.index,
                                                                                                            parsed = data.parsed[index],
                                                                                    Severity: Major
                                                                                    Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 40 mins to fix

                                                                                      Consider simplifying this complex logical expression.
                                                                                      Open

                                                                                                      if ( tsfRegex.andTest.test( data.filter ) ) {
                                                                                                          var indx, filterMatched, result, query, regex,
                                                                                                              // duplicate data but split filter
                                                                                                              data2 = $.extend( {}, data ),
                                                                                                              filter = data.filter.split( tsfRegex.andSplit ),
                                                                                      Severity: Major
                                                                                      Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 40 mins to fix

                                                                                        Consider simplifying this complex logical expression.
                                                                                        Open

                                                                                                        if ( $header && $header.length ) {
                                                                                                            // $filter = c.$filters.filter( '[data-column="' + column + '"]' );
                                                                                                            $filter = tsf.getColumnElm( c, c.$filters, column );
                                                                                                            ffxn = ts.getColumnData( table, wo.filter_functions, column );
                                                                                                            makeSelect = ( wo.filter_functions && ffxn && typeof ffxn !== 'function' ) ||
                                                                                        Severity: Major
                                                                                        Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 40 mins to fix

                                                                                          Function buildSelect has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                                                          Open

                                                                                                  buildSelect: function( table, column, arry, updating, onlyAvail ) {
                                                                                          Severity: Minor
                                                                                          Found in media/jquery/tablesorter-master/js/widgets/widget-filter.js - About 35 mins to fix

                                                                                            There are no issues that match your filters.

                                                                                            Category
                                                                                            Status