Passed
Branch v1.0.x (02a8e5)
by Rafael S.
03:09
created

dist/ieee754-buffer.js   A

Complexity

Total Complexity 28
Complexity/F 4

Size

Lines of Code 4
Function Count 7

Duplication

Duplicated Lines 1
Ratio 25 %

Importance

Changes 0
Metric Value
wmc 28
eloc 4
mnd 21
bc 21
fnc 7
dl 1
loc 4
rs 10
bpm 3
cpm 4
noi 11
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1 View Code Duplication
(function(h,g){"object"===typeof exports&&"undefined"!==typeof module?g(exports):"function"===typeof define&&define.amd?define(["exports"],g):(h=h||self,g(h.IEEE754Buffer={}))})(this,function(h){var g=function(e,a){this.ebits=e;this.fbits=a;this.bias=(1<<e-1)-1;this.numBytes=Math.ceil((e+a)/8);this.biasP2=Math.pow(2,this.bias+1);this.ebitsFbits=e+a;this.fbias=Math.pow(2,-(8*this.numBytes-1-e))};g.prototype.pack=function(e,a,f){Math.abs(a)>this.biasP2-2*this.ebitsFbits&&(a=0>a?-Infinity:Infinity);
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
If you intend to check if the variable self is declared in the current environment, consider using typeof self === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
var d=0>((a=+a)||1/a)?1:0>a?1:0;a=Math.abs(a);var c=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),b=this.roundToEven(a/Math.pow(2,c)*Math.pow(2,this.fbits));a!==a?(b=Math.pow(2,this.fbits-1),c=(1<<this.ebits)-1):0!==a&&(a>=Math.pow(2,1-this.bias)?(2<=b/Math.pow(2,this.fbits)&&(c+=1,b=1),c>this.bias?(c=(1<<this.ebits)-1,b=0):(c+=this.bias,b=this.roundToEven(b)-Math.pow(2,this.fbits))):(b=this.roundToEven(a/Math.pow(2,1-this.bias-this.fbits)),c=0));return this.packFloatBits_(e,f,d,c,b)};g.prototype.unpack=
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
3
function(e,a){for(var f=(1<<this.ebits)-1,d="",c=this.numBytes-1;0<=c;c--){var b=e[c+a].toString(2);d+="00000000".substring(b.length)+b}c="1"==d.charAt(0)?-1:1;d=d.substring(1);b=parseInt(d.substring(0,this.ebits),2);d=d.substring(this.ebits);if(b==f)return 0!==parseInt(d,2)?NaN:Infinity*c;0===b?(b+=1,f=parseInt(d,2)):f=parseInt("1"+d,2);return c*f*this.fbias*Math.pow(2,b-this.bias)};g.prototype.packFloatBits_=function(e,a,f,d,c){var b=[];b.push(f);for(f=this.ebits;0<f;--f)b[f]=d%2?1:0,d=Math.floor(d/
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable c here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
4
2);d=b.length;for(f=this.fbits;0<f;--f)b[d+f]=c%2?1:0,c=Math.floor(c/2);c=b.join("");b=this.numBytes+a-1;for(d=a;b>=a;)e[b]=parseInt(c.substring(0,8),2),c=c.substring(8),b--,d++;return d};g.prototype.roundToEven=function(e){var a=Math.floor(e);e-=a;return.5>e?a:.5<e?a+1:a%2?a+1:a};h.IEEE754Buffer=g;Object.defineProperty(h,"__esModule",{value:!0})});
0 ignored issues
show
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable b here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable d here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
5