Passed
Branch main (ae8397)
by Ilya
01:02
created

demo/libs/utilities.js   A

Complexity

Total Complexity 16
Complexity/F 1.14

Size

Lines of Code 80
Function Count 14

Duplication

Duplicated Lines 80
Ratio 100 %

Importance

Changes 0
Metric Value
wmc 16
eloc 45
mnd 2
bc 2
fnc 14
dl 80
loc 80
rs 10
bpm 0.1428
cpm 1.1428
noi 6
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
window.Utilities={random_int:function(t,n){return Math.floor(Math.random()*(n-t)+t)},urandom:function(t){let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(Utilities.random_int(0,256));return n},fillArray:function(t,n){const r=[];for(let e=0;e<n;e++)r.push(t);return r},arrToInt:function(t){return parseInt(Array.prototype.map.call(t,t=>("00"+t.toString(16)).slice(-2)).join(""),16)},fileReader:function(t){let n=0,r=t;function e(r){let e=t.slice(n,n+r);return n+=r,e}return{readByte:function(){return e(1)[0]},readBytes:e,readBytesAsInt:function(t){return Utilities.arrToInt(e(t))},readBytesAsString:function(t){return Utilities.bytes_to_latin1(e(t))},getCurrentPosition:function(){return n},getLength:function(){return r.length}}},bytes_to_latin1:function(t){return CryptoJS.enc.Latin1.stringify(CryptoJS.enc.Uint8Arr.parse(t))},encode_to_words:function(t,n="Latin1"){return CryptoJS.enc[n].parse(t)}};