mambax7/alumni-26x

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

Summary

Maintainability
D
1 day
Test Coverage

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

/*! Widget: output - updated 9/27/2017 (v2.29.0) *//*
 * Requires tablesorter v2.8+ and jQuery 1.7+
 * Modified from:
 * HTML Table to CSV: http://www.kunalbabre.com/projects/table2CSV.php (License unknown?)
 * Download-File-JS: https://github.com/PixelsCommander/Download-File-JS (http://www.apache.org/licenses/LICENSE-2.0)
Severity: Minor
Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 3 hrs to fix

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

            process : function(c, wo, $rows, dump) {
                var mydata, $this, headers, csvData, len, rowsLen, tmp,
                    hasStringify = window.JSON && JSON.hasOwnProperty('stringify'),
                    indx = 0,
                    tmpData = (wo.output_separator || ',').toLowerCase(),
    Severity: Major
    Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 2 hrs to fix

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

              processRow: function(c, $rows, isHeader, isJSON) {
                  var $cell, $cells, cellsLen, rowIndex, row, col, indx, rowspanLen, colspanLen, txt,
                      wo = c.widgetOptions,
                      tmpRow = [],
                      dupe = wo.output_duplicateSpans,
      Severity: Minor
      Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 1 hr to fix

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

                download : function (c, wo, data) {
        
                    if (typeof wo.output_savePlugin === 'function') {
                        return wo.output_savePlugin(c, wo, data);
                    }
        Severity: Minor
        Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 1 hr to fix

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

                  formatData : function(c, wo, $el, isHeader) {
                      var attr = $el.attr(wo.output_dataAttrib),
                          txt = typeof attr !== 'undefined' ? attr : $el.html(),
                          quotes = (wo.output_separator || ',').toLowerCase(),
                          separator = quotes === 'json' || quotes === 'array',
          Severity: Minor
          Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
            Severity: Major
            Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if ($cell.filter('[rowspan]').length) {
                                              rowspanLen = parseInt( $cell.attr('rowspan'), 10);
                                              for (row = 0; row < rowspanLen; row++) {
                                                  if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
                                                  tmpRow[rowIndex + row][cellIndex + col] = addSpanIndex ?
              Severity: Major
              Found in media/jquery/tablesorter-master/js/widgets/widget-output.js - About 45 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                                    tmpRow[rowIndex + row][cellIndex + col] = addSpanIndex ?
                                                        wo.output_callbackJSON($cell, txt, cellIndex + col) ||
                                                        txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
                Severity: Minor
                Found in media/jquery/tablesorter-master/js/widgets/widget-output.js and 1 other location - About 55 mins to fix
                media/jquery/tablesorter-master/js/widgets/widget-output.js on lines 99..101

                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 54.

                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

                                                tmpRow[rowIndex][cellIndex + col] = addSpanIndex ?
                                                    wo.output_callbackJSON($cell, txt, cellIndex + col) ||
                                                    txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
                Severity: Minor
                Found in media/jquery/tablesorter-master/js/widgets/widget-output.js and 1 other location - About 55 mins to fix
                media/jquery/tablesorter-master/js/widgets/widget-output.js on lines 94..96

                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 54.

                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