File widget-math.js
has 536 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*! Widget: math - updated 5/3/2017 (v2.28.9) *//*
* Requires tablesorter v2.16+ and jQuery 1.7+
* by Rob Garrison
*/
/*jshint browser:true, jquery:true, unused:false */
Function getColumn
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
getColumn : function( c, $el, type, hasFilter ) {
var index, $t, $tr, len, $mathRows, mathAbove,
wo = c.widgetOptions,
arry = [],
$row = $el.closest( 'tr' ),
Function formatMask
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
ts.formatMask = function( mask, val, tmpPrefix, tmpSuffix ) {
if ( !mask || isNaN( +val ) ) {
return val; // return as it is.
}
Function recalculate
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
recalculate : function(c, wo, init) {
if ( c && ( !wo.math_isUpdating || init ) ) {
var undef, time, mathAttr, $mathCells, indx, len,
changed = false,
Function mathType
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
mathType : function( c, $cells, priority, hasFilter ) {
if ( $cells.length ) {
var getAll,
changed = false,
wo = c.widgetOptions,
Function output
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
output : function( $cell, c, value, arry ) {
// get mask from cell data-attribute: data-math-mask="#,##0.00"
var $el,
wo = c.widgetOptions,
changed = false,
Function getAll
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getAll : function( c, hasFilter ) {
var $t, col, $row, rowIndex, rowLen, $cells, cellIndex, cellLen,
arry = [],
wo = c.widgetOptions,
mathAttr = wo.math_dataAttrib,
Consider simplifying this complex logical expression. Open
if ( c && ( !wo.math_isUpdating || init ) ) {
var undef, time, mathAttr, $mathCells, indx, len,
changed = false,
filters = {};
Avoid deeply nested control flow statements. Open
if ( arry.length ) {
result = equations[ formula ]( arry, c );
if ( c.debug || wo.math_debug ) {
console.log( $el.attr( mathAttr ), hasFilter ? '("' + hasFilter + '")' : '', arry, '=', result );
}
Consider simplifying this complex logical expression. Open
if ( ( ( hasFilter || !$tr.hasClass( filtered ) ) &&
$tr.not( mathIgnore ).length &&
index !== len ) ||
mathAbove && index !== len ) {
// stop calculating 'above', when encountering another 'above'
Identical blocks of code found in 2 locations. Consider refactoring. Open
$t = $tr.children().filter( function() {
return math.getCellIndex( $( this ) ) === cIndex;
});
- 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 46.
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
$t = $tr.children().filter( function() {
return math.getCellIndex( $( this ) ) === cIndex;
});
- 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 46.
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
stdevp : function( arry, c ) {
var varp = ts.equations.variance( arry, true, c );
return Math.sqrt( varp );
}
- 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 46.
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
stdevs : function( arry, c ) {
var vars = ts.equations.variance( arry, false, c );
return Math.sqrt( vars );
},
- 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 46.
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